public function testRender() { $asserts = new Assets(); $asserts->fromArray(['foo' => 'foo.js', 'bar' => ['bar.js'], 'baz' => ['extends' => 'bar'], 'qux' => ['extends' => ['foo', 'baz'], 'sources' => ['qux.js', 'qux.css']]]); $asserts->uses('qux'); $expected = '<link href="qux.css" rel="stylesheet" />' . PHP_EOL . '<script src="foo.js"></script>' . PHP_EOL . '<script src="bar.js"></script>' . PHP_EOL . '<script src="qux.js"></script>'; $result = $asserts->render(); $this->assertSame($expected, $result); }
public function getJs() { $sources = []; foreach ($this->parents as $parentGroupName) { $sources = array_replace($sources, $this->assets->getGroup($parentGroupName)->getJs()); } $sources = array_replace($sources, $this->js); foreach ($sources as &$source) { $source = $this->assets->prepareSource($source); } return $sources; }