/** * Test Javascript add/remove. * * @return void */ public function testJs() { $container = new ResourceContainer(); $container->addJs(['a', 'b', 'c']); $container->addJs('c'); $container->addJs('d'); $this->assertEquals([], array_diff(['a', 'b', 'c', 'd'], $container->getJs())); }
/** * Add scripts to header. * * @return void */ protected function addScripts() { // Load Javascript (same ordering considerations as CSS, above): $headScript = $this->getView()->plugin('headscript'); foreach (array_reverse($this->container->getJs()) as $current) { $parts = $this->parseSetting($current); $headScript()->prependFile(trim($parts[0]), 'text/javascript', isset($parts[1]) ? ['conditional' => trim($parts[1])] : []); } }