Commit d82a3f41 authored by Taylor Otwell's avatar Taylor Otwell

added asset dependency tests.

parent ed9e04db
......@@ -63,7 +63,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
);
}
public function testStylesCanBeRetrieved()
public function testAllStylesCanBeRetrievedViaStylesMethod()
{
$container = new Laravel\Asset_Container('default', new HTMLAssetStub);
......@@ -74,7 +74,7 @@ class AssetTest extends PHPUnit_Framework_TestCase {
$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);
......@@ -85,6 +85,43 @@ class AssetTest extends PHPUnit_Framework_TestCase {
$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()
{
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