Esempio n. 1
0
 protected function initialiseDefaultValues()
 {
     parent::initialiseDefaultValues();
     $request = Context::currentRequest();
     $host = $request->Server("SERVER_NAME");
     $this->DefaultSender = new EmailAddress("donotreply@" . $host . ".com");
 }
Esempio n. 2
0
 public function testPayload()
 {
     $testPayload = new \stdClass();
     $testPayload->a = 1;
     $testPayload->b = 2;
     $this->context->SimulatedRequestBody = json_encode($testPayload);
     $request = Context::currentRequest();
     $this->assertEquals($testPayload, $request->getPayload());
 }
Esempio n. 3
0
 public function testRequestAccess()
 {
     $context = new Context();
     $context->SimulateNonCli = false;
     unset($this->context->Request);
     $this->assertNotNull(Context::CurrentRequest(), "Static Request accessor returned NULL");
     $this->assertNotNull($this->context->Request, "Request accessor returned NULL");
     $this->assertInstanceOf('\\Rhubarb\\Crown\\Request\\CliRequest', Context::CurrentRequest());
 }
Esempio n. 4
0
 public static function setUpBeforeClass()
 {
     Module::RegisterModule(new UnitTestingModule());
     Module::InitialiseModules();
     $context = new Context();
     $context->UnitTesting = true;
     $context->SimulateNonCli = false;
     $request = Context::CurrentRequest();
     $request->Reset();
 }
 public function testEmptyValuesAreRemoved()
 {
     $request = Context::CurrentRequest();
     $request->Post("Test", array(0, 1, 2, 3, 0));
     $result = false;
     $dropDown = new RepeatingDropDown("Test");
     $dropDown->AttachEventHandler("SetBoundData", function ($presenter, $data) use(&$result) {
         $result = $data;
     });
     $dropDown->GenerateResponse($request);
     $this->assertEquals([1, 2, 3], $result);
 }
 protected function setUp()
 {
     $this->request = Context::CurrentRequest();
     $this->request->IsWebRequest = true;
     LayoutModule::disableLayout();
 }
Esempio n. 7
0
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
/**
 * execute-http.php is the entry point for all HTTP requests for Rhubarb applications.
 * The only exceptions to this are when webserver URL rewriting goes directly to
 * a resource for performance reasons, e.g. accessing static content like images
 * and CSS files.
 */
use Rhubarb\Crown\Logging\Log;
use Rhubarb\Crown\Module;
// Change the working directory to the top level project folder.
chdir(__DIR__ . "/../../../../");
// Initiate our bootstrap script to boot all libraries required.
require_once __DIR__ . "/boot.php";
require_once __DIR__ . "/../src/Module.php";
require_once __DIR__ . "/../src/Context.php";
$request = \Rhubarb\Crown\Context::currentRequest();
try {
    // Pass control to the Module class and ask it to generate a response for the
    // incoming request.
    $response = Module::generateResponseForRequest($request);
    $response->send();
} catch (\Exception $er) {
    $context = new \Rhubarb\Crown\Context();
    if ($context->DeveloperMode) {
        Log::error($er->getMessage(), "ERROR");
        print "<pre>Exception: " . get_class($er) . "\nMessage: " . $er->getMessage() . "\nStack Trace:\n" . $er->getTraceAsString();
    }
}
Log::debug("Request Complete", "ROUTER");
Esempio n. 8
0
 protected function getAbsoluteHandledUrl()
 {
     $request = Context::currentRequest();
     return $request->Server("REQUEST_SCHEME") . "://" . $request->Server("SERVER_NAME") . $this->handledUrl;
 }
Esempio n. 9
0
 public function getPayload()
 {
     $context = new Context();
     $requestBody = trim($context->getRequestBody());
     return json_decode($requestBody);
 }
 public function setUp()
 {
     $this->request = Context::currentRequest();
     $this->request->IsWebRequest = true;
 }