/** * Method to test reset(). * * @return void * * @covers Windwalker\Script\AbstractScriptManager::reset */ public function testReset() { CoreScript::requireJS(); $inited = $this->readAttribute('Windwalker\\Script\\AbstractScriptManager', 'inited'); $this->assertEquals(array('a03e9ce134099d2bd410bdc53e8abb7d3f95c397' => true), $inited['Windwalker\\Script\\CoreScript']['Windwalker\\Script\\CoreScript::requireJS']); StubScript::reset(); $inited = $this->readAttribute('Windwalker\\Script\\AbstractScriptManager', 'inited'); $this->assertEquals(array('a03e9ce134099d2bd410bdc53e8abb7d3f95c397' => true), $inited['Windwalker\\Script\\CoreScript']['Windwalker\\Script\\CoreScript::requireJS']); AbstractScriptManager::reset(); $inited = $this->readAttribute('Windwalker\\Script\\AbstractScriptManager', 'inited'); $this->assertEmpty($inited); CoreScript::requireJS(); StubScript::reset(true); $inited = $this->readAttribute('Windwalker\\Script\\AbstractScriptManager', 'inited'); $this->assertEmpty($inited); }
/** * Method to test backbone(). * * @return void * * @covers Windwalker\Script\CoreScript::backbone */ public function testBackbone() { $bakDoc = \JFactory::getDocument(); \JFactory::$document = $this->doc; TestHelper::setValue('JHtmlJquery', 'loaded', array()); CoreScript::backbone(false); $url = \JUri::root(true) . '/libraries/windwalker/resource/asset/js/core/backbone.js'; $this->assertEquals($url, $this->doc->getLastScript()); $this->assertEquals(5, count($this->doc->_scripts)); $js = <<<JS ; _.templateSettings = { interpolate: /\\{\\{(.+?)\\}\\}/g };; ; var underscore = _.noConflict();; JS; $this->assertStringDataEquals($js, $this->doc->_script['text/javascript']); CoreScript::backbone(true); $url = \JUri::root(true) . '/libraries/windwalker/resource/asset/js/core/backbone.js'; $this->assertEquals($url, $this->doc->getLastScript()); $this->assertEquals(5, count($this->doc->_scripts)); $js = <<<JS ; _.templateSettings = { interpolate: /\\{\\{(.+?)\\}\\}/g };; ; var underscore = _.noConflict();; ; var backbone = Backbone.noConflict();; JS; $this->assertStringDataEquals($js, $this->doc->_script['text/javascript']); \JFactory::$document = $bakDoc; }