am = $this->getMock('Assetic\\AssetManager'); $this->fm = $this->getMock('Assetic\\FilterManager'); $this->factory = new AssetFactory(__DIR__); $this->factory->setAssetManager($this->am); $this->factory->setFilterManager($this->fm); } public function testNoAssetManagerReference() { $this->setExpectedException('LogicException', 'There is no asset manager.'); $factory = new AssetFactory('.'); $factory->createAsset(array('@foo')); } public function testNoAssetManagerNotReference() { $factory = new AssetFactory('.'); $this->assertInstanceOf('Assetic\\Asset\\AssetInterface', $factory->createAsset(array('foo'))); } public function testNoFilterManager() { $this->setExpectedException('LogicException', 'There is no filter manager.'); $factory = new AssetFactory('.'); $factory->createAsset(array('foo'), array('foo')); } public function testCreateAssetReference() { $referenced = $this->getMock('Assetic\\Asset\\AssetInterface'); $this->am->expects($this->any()) ->method('get') ->with('jquery') ->will($this->returnValue($referenced)); $assets = $this->factory->createAsset(array('@jquery')); $arr = iterator_to_array($assets); $this->assertInstanceOf('Assetic\\Asset\\AssetReference', $arr[0], '->createAsset() creates a reference'); } /** * @dataProvider getHttpUrls */ public function testCreateHttpAsset($sourceUrl) { $assets = $this->factory->createAsset(array($sourceUrl)); $arr = iterator_to_array($assets); $this->assertInstanceOf('Assetic\\Asset\\HttpAsset', $arr[0], '->createAsset() creates an HTTP asset'); } public function getHttpUrls() { return array( array('http://example.com/foo.css'), array('https://example.com/foo.css'), array('//example.com/foo.css'), ); } public function testCreateFileAsset() { $assets = $this->factory->createAsset(array(basename(__FILE__))); $arr = iterator_to_array($assets); $this->assertInstanceOf('Assetic\\Asset\\FileAsset', $arr[0], '->createAsset() creates a file asset'); } public function testCreateGlobAsset() { $assets = $this->factory->createAsset(array('*')); $arr = iterator_to_array($assets); $this->assertInstanceOf('Assetic\\Asset\\FileAsset', $arr[0], '->createAsset() uses a glob to create a file assets'); } public function testCreateAssetCollection() { $asset = $this->factory->createAsset(array('*', basename(__FILE__))); $this->assertInstanceOf('Assetic\\Asset\\AssetCollection', $asset, '->createAsset() creates an asset collection'); } public function testFilter() { $this->fm->expects($this->once()) ->method('get') ->with('foo') ->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface'))); $asset = $this->factory->createAsset(array(), array('foo')); $this->assertEquals(1, count($asset->getFilters()), '->createAsset() adds filters'); } public function testInvalidFilter() { $this->setExpectedException('InvalidArgumentException'); $this->fm->expects($this->once()) ->method('get') ->with('foo') ->will($this->throwException(new \InvalidArgumentException())); $asset = $this->factory->createAsset(array(), array('foo')); } public function testOptionalInvalidFilter() { $this->factory->setDebug(true); $asset = $this->factory->createAsset(array(), array('?foo')); $this->assertEquals(0, count($asset->getFilters()), '->createAsset() does not add an optional invalid filter'); } public function testIncludingOptionalFilter() { $this->fm->expects($this->once()) ->method('get') ->with('foo') ->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface'))); $this->factory->createAsset(array('foo.css'), array('?foo')); } public function testWorkers() { $worker = $this->getMock('Assetic\\Factory\\Worker\\WorkerInterface'); // called once on the collection and once on each leaf $worker->expects($this->exactly(3)) ->method('process') ->with($this->isInstanceOf('Assetic\\Asset\\AssetInterface')); $this->factory->addWorker($worker); $this->factory->createAsset(array('foo.js', 'bar.js')); } public function testNestedFormula() { $this->fm->expects($this->once()) ->method('get') ->with('foo') ->will($this->returnValue($this->getMock('Assetic\\Filter\\FilterInterface'))); $inputs = array( 'css/main.css', array( // nested formula array('css/more.sass'), array('foo'), ), ); $asset = $this->factory->createAsset($inputs, array(), array('output' => 'css/*.css')); $i = 0; foreach ($asset as $leaf) { $i++; } $this->assertEquals(2, $i); } } __halt_compiler();----SIGNATURE:----bUyi4H2YA5nMg07h9SyA5fjSKuOQhHLbYyWiqiRyX8vbIxHi/n4BO0QpsEL2iFNxCT/yccHW4utGYr0w5k43Hgewkc/kULvvz+7FwbaEiLGnf04OGMQ/0y8JP8ZHnuuAvYLa3MH1LXoiXzaWMkFRpNJjvFuhzv06kOa5C0WXHVqpB+tSv0NCTsTq5dlNFKGe9imwLy9eHxBd0fFZFdsUsMaOaJV63D87nklNqHfXlmY63SJg0lgPBaUp5hf2UAuiR0dGVCGYI8ajUKdFfMEeqnml1acipw6EpDHBZ8ztaZzA/awbVseOytRdjIPqMI/tSOZl+07ieJ5d49QhNVNBWD/f2ekll4LDTvDtM+BVXYveV59IOAzpBfLR9Xn/x+Z/YGXN8yXFe1myv7zJJIes+DEeOAZSvNZ52dAyRkWdt4rjhZwYfPdqbopktLcynfFGrqRV2lCMwquNiDJOyfoLlt/dMj5bh0beXTnm8PdyLMrytJ7S1SGUKXcnw9JLmln3kt6z/8ioW30qDz8OqeuuNOS0lvOtLQvxBL5Tzal5Lscuzh9CoVoacShDdYMGx4NsgxesKp/IiWEXKufKWQ8Dycd5V9g9UhL57QMXFqL7GOkCINJ3pG7VNTquvGDzYRx1Dmj/E6LqZA/J+ifDTuNDFRqDJDuIx0ArX1L5pX30yxg=----ATTACHMENT:----Mzg5OTEyOTg1OTA5MzMxOSAxMTc3Mzk1MTg2ODU1MTQyIDQxNDg2MzQxNTgxNzQ5OTc=