/**
  * Tests the JDispatcher::getInstance method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testGetInstance()
 {
     $instance = JDispatcher::getInstance();
     $this->assertInstanceOf('JDispatcher', $instance, 'Tests that getInstance returns a JDispatcher object.');
     // Push a new instance into the class.
     JDispatcherInspector::setInstance('foo');
     $this->assertThat(JDispatcher::getInstance(), $this->equalTo('foo'), 'Tests that a subsequent call to JDispatcher::getInstance returns the cached singleton.');
 }
Exemplo n.º 2
0
 /**
  * Overrides the parent tearDown method.
  *
  * @return  void
  *
  * @see     PHPUnit_Framework_TestCase::tearDown()
  * @since   11.1
  */
 protected function tearDown()
 {
     // Reset the dispatcher instance.
     JDispatcherInspector::setInstance(null);
     // Reset the loaded plugins.
     JPluginHelperInspector::setPlugins(null);
     parent::tearDown();
 }
Exemplo n.º 3
0
 /**
  * Allows the internal singleton to be set and mocked.
  *
  * @param   JDispatcher  $instance  A dispatcher object.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function setInstance($instance)
 {
     self::$instance = $instance;
 }
Exemplo n.º 4
0
 /**
  * Tests the JApplicationWeb::loadDocument method.
  *
  * @return  void
  *
  * @since   11.3
  */
 public function testLoadDocument()
 {
     // Inject the mock dispatcher into the JDispatcher singleton.
     JDispatcherInspector::setInstance($this->getMockDispatcher());
     $this->inspector->loadDocument();
     $this->assertInstanceOf('JDocument', $this->inspector->getClassProperty('document'), 'Tests that the document object is the correct class.');
     $this->assertThat($this->inspector->getClassProperty('document')->test(), $this->equalTo('ok'), 'Tests that we got the document from the factory.');
 }