コード例 #1
0
 /**
  * Tests the JApplicationCms::Execute method with a document.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testExecuteWithDocument()
 {
     $document = $this->getMockDocument();
     $this->assignMockReturns($document, array('render' => 'JWeb Body'));
     // Manually inject the document.
     $this->class->loadDocument($document);
     // Buffer the execution.
     ob_start();
     $this->class->execute();
     $buffer = ob_get_contents();
     ob_end_clean();
     $this->assertEquals('JWeb Body', $this->class->getBody());
     $this->assertEquals('JWeb Body', $buffer);
 }
コード例 #2
0
 /**
  * Tests the JApplicationCms::Execute method with a document.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testExecuteWithDocument()
 {
     JFactory::$application = $this->class;
     $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('JWebDoExecute', 'JWebTestExecute-JWebDoExecute')->registerEvent('onBeforeRender', 'JWebTestExecute-onBeforeRender')->registerEvent('onAfterRender', 'JWebTestExecute-onAfterRender')->registerEvent('onAfterRespond', 'JWebTestExecute-onAfterRespond');
     // Buffer the execution.
     ob_start();
     $this->class->execute();
     $buffer = ob_get_contents();
     ob_end_clean();
     $this->assertEquals(array('JWebDoExecute', 'onBeforeRender', 'onAfterRender', 'onAfterRespond'), TestMockDispatcher::$triggered);
     $this->assertEquals('JWeb Body', $this->class->getBody());
     $this->assertEquals('JWeb Body', $buffer);
 }
コード例 #3
0
 /**
  * Tests the JApplicationCms::Execute method with a document.
  *
  * @return  void
  *
  * @since   3.2
  */
 public function testExecuteWithDocument()
 {
     JFactory::$application = $this->class;
     $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('JWebDoExecute', 'JWebTestExecute-JWebDoExecute')->registerEvent('onBeforeRender', 'JWebTestExecute-onBeforeRender')->registerEvent('onAfterRender', 'JWebTestExecute-onAfterRender')->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('JWebDoExecute', 'onBeforeRender', 'onAfterRender', '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.');
 }