Commit d82a3f41 authored by Taylor Otwell's avatar Taylor Otwell

added asset dependency tests.

parent ed9e04db
...@@ -20,7 +20,7 @@ class AssetTest extends PHPUnit_Framework_TestCase { ...@@ -20,7 +20,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
$mock = $this->getMockBuilder('Laravel\\Asset_Container')->disableOriginalConstructor()->getMock(); $mock = $this->getMockBuilder('Laravel\\Asset_Container')->disableOriginalConstructor()->getMock();
$mock->expects($this->any())->method('styles')->will($this->returnValue('styles')); $mock->expects($this->any())->method('styles')->will($this->returnValue('styles'));
$asset->containers['default'] = $mock; $asset->containers['default'] = $mock;
$this->assertEquals($asset->styles(), 'styles'); $this->assertEquals($asset->styles(), 'styles');
...@@ -63,7 +63,7 @@ class AssetTest extends PHPUnit_Framework_TestCase { ...@@ -63,7 +63,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
); );
} }
public function testStylesCanBeRetrieved() public function testAllStylesCanBeRetrievedViaStylesMethod()
{ {
$container = new Laravel\Asset_Container('default', new HTMLAssetStub); $container = new Laravel\Asset_Container('default', new HTMLAssetStub);
...@@ -74,7 +74,7 @@ class AssetTest extends PHPUnit_Framework_TestCase { ...@@ -74,7 +74,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($container->styles(), 'css/reset.css media:allcss/jquery.css media:all'); $this->assertEquals($container->styles(), 'css/reset.css media:allcss/jquery.css media:all');
} }
public function testScriptsCanBeRetrieved() public function testAllScriptsCanBeRetrievedViaScriptsMethod()
{ {
$container = new Laravel\Asset_Container('default', new HTMLAssetStub); $container = new Laravel\Asset_Container('default', new HTMLAssetStub);
...@@ -85,6 +85,43 @@ class AssetTest extends PHPUnit_Framework_TestCase { ...@@ -85,6 +85,43 @@ class AssetTest extends PHPUnit_Framework_TestCase {
$this->assertEquals($container->scripts(), 'js/jquery-ui.js js/jquery.js test:value'); $this->assertEquals($container->scripts(), 'js/jquery-ui.js js/jquery.js test:value');
} }
public function testAssetsAreSortedBasedOnDependencies()
{
$container = $this->getContainer();
$container->script('jquery', 'js/jquery.js', array('jquery-ui'));
$container->script('jquery-ui', 'js/jquery-ui.js');
$scripts = $container->scripts();
$this->assertTrue(strpos($scripts, 'js/jquery-ui.js') < strpos($scripts, 'js/jquery.js'));
}
/**
* @expectedException Exception
*/
public function testAssetsCannotBeDependentOnSelf()
{
$container = $this->getContainer();
$container->script('jquery', 'js/jquery.js', array('jquery'));
$container->scripts();
}
/**
* @expectedException Exception
*/
public function testAssetDependenciesCannotBeCircular()
{
$container = $this->getContainer();
$container->script('jquery', 'js/jquery.js', array('jquery-ui'));
$container->script('jquery-ui', 'js/jquery-ui.js', array('jquery'));
$container->scripts();
}
private function getContainer() private function getContainer()
{ {
return new Laravel\Asset_Container('default', Laravel\IoC::resolve('laravel.html')); return new Laravel\Asset_Container('default', Laravel\IoC::resolve('laravel.html'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment