/** * 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.'); }
/** * 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(); }
/** * 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; }
/** * 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.'); }