/** * Tests the JApplicationWeb::Execute method with a document. * * @return void * * @since 11.3 */ public function testExecuteWithDocument() { $dispatcher = $this->getMockDispatcher(); $document = $this->getMockDocument(); $this->assignMockReturns($document, array('render' => 'JWeb Body')); // Manually inject the dispatcher. TestReflection::setValue($this->class, 'dispatcher', $dispatcher); TestReflection::setValue($this->class, 'document', $document); // Register all the methods so that we can track if they have been fired. $this->class->registerEvent('onBeforeExecute', 'JWebTestExecute-onBeforeExecute') ->registerEvent('JWebDoExecute', 'JWebTestExecute-JWebDoExecute') ->registerEvent('onAfterExecute', 'JWebTestExecute-onAfterExecute') ->registerEvent('onBeforeRender', 'JWebTestExecute-onBeforeRender') ->registerEvent('onAfterRender', 'JWebTestExecute-onAfterRender') ->registerEvent('onBeforeRespond', 'JWebTestExecute-onBeforeRespond') ->registerEvent('onAfterRespond', 'JWebTestExecute-onAfterRespond'); // Buffer the execution. ob_start(); $this->class->execute(); $buffer = ob_get_contents(); ob_end_clean(); $this->assertThat( TestMockDispatcher::$triggered, $this->equalTo( array( 'onBeforeExecute', 'JWebDoExecute', 'onAfterExecute', 'onBeforeRender', 'onAfterRender', 'onBeforeRespond', 'onAfterRespond', ) ), 'Check that events fire in the right order (with document).' ); $this->assertThat( $this->class->getBody(), $this->equalTo('JWeb Body'), 'Check that the body was set with the return value of document render method.' ); $this->assertThat( $buffer, $this->equalTo('JWeb Body'), 'Check that the body is output correctly.' ); }
/** * Tests the JApplicationWeb::Execute method with a document. * * @return void * * @since 11.3 */ public function testExecuteWithDocument() { $dispatcher = $this->getMockDispatcher(); $document = $this->getMockDocument(); $this->assignMockReturns($document, array('render' => 'JWeb Body')); // Manually inject the mocks. $this->class->setDispatcher($dispatcher); $this->class->loadDocument($document); // Buffer the execution. ob_start(); $this->class->execute(); $buffer = ob_get_clean(); $this->assertEquals('JWeb Body', $this->class->getBody()); $this->assertEquals('JWeb Body', $buffer); }
/** * Tests the JApplicationWeb::Execute method with a document. * * @return void * * @since 11.3 */ public function testExecuteWithDocument() { $dispatcher = $this->getMockDispatcher(); $document = $this->getMockDocument(); $this->assignMockReturns($document, array('render' => 'JWeb Body')); // Manually inject the mocks. TestReflection::setValue($this->class, 'dispatcher', $dispatcher); TestReflection::setValue($this->class, 'document', $document); // Register all the methods so that we can track if they have been fired. $this->class->registerEvent('onBeforeExecute', 'JWebTestExecute-onBeforeExecute')->registerEvent('JWebDoExecute', 'JWebTestExecute-JWebDoExecute')->registerEvent('onAfterExecute', 'JWebTestExecute-onAfterExecute')->registerEvent('onBeforeRender', 'JWebTestExecute-onBeforeRender')->registerEvent('onAfterRender', 'JWebTestExecute-onAfterRender')->registerEvent('onBeforeRespond', 'JWebTestExecute-onBeforeRespond')->registerEvent('onAfterRespond', 'JWebTestExecute-onAfterRespond'); // Buffer the execution. ob_start(); $this->class->execute(); $buffer = ob_get_clean(); $this->assertEquals(array('onBeforeExecute', 'JWebDoExecute', 'onAfterExecute', 'onBeforeRender', 'onAfterRender', 'onBeforeRespond', 'onAfterRespond'), TestMockDispatcher::$triggered); $this->assertEquals('JWeb Body', $this->class->getBody()); $this->assertEquals('JWeb Body', $buffer); }