/** * Tests the getInstance() method * * @return void * * @since 3.4 */ public function testGetInstance() { // Check if a proper object is returned and that the mode is properly set JRouterInspector::clearInstanceCache(); $object = JRouter::getInstance('administrator', array('mode' => 'test', 'randomKey' => 'randomValue')); $this->assertTrue(is_a($object, 'JRouterAdministrator')); $this->assertEquals($object->getMode(), 'test'); // This test is commented, since the feature is not implemented (yet) // $this->assertEquals($object->get('randomKey'), 'randomValue'); // Check if the same object is returned by getInstance() $object2 = JRouter::getInstance('administrator'); $this->assertSame($object, $object2); require_once JPATH_TESTS . '/suites/libraries/cms/application/stubs/JApplicationHelperInspector.php'; $apps = JApplicationHelperInspector::get(); $obj = new stdClass(); $obj->id = 3; $obj->name = 'tester'; $obj->path = dirname(__FILE__) . '/example'; $apps[3] = $obj; JApplicationHelperInspector::set($apps); // Test if legacy app routers are still loaded $object3 = JRouter::getInstance('tester'); $this->assertTrue(is_a($object, 'JRouter')); }
/** * Set the application data. * * @param string $apps The app to set. * * @return void */ public static function set($apps) { self::$_clients = $apps; }