target() public method

Create a single build target
public target ( string $name ) : AssetTarget
$name string The name of the target to build
return AssetTarget
 /**
  * @expectedException RuntimeException
  * @expectedExceptionMessage Callback MiniAsset\Test\Helpers\MyCallbackProvider::invalid() is not callable
  */
 public function testCallbackProviderNotCallable()
 {
     $callbacksFile = APP . 'config' . DS . 'callbacks.ini';
     $config = AssetConfig::buildFromIniFile($callbacksFile);
     $factory = new Factory($config);
     $target = $factory->target('callbacks_not_callable.js');
 }
 /**
  * Get an asset from the collection
  *
  * @param string $name The name of the asset you want.
  * @return null|AssetTarget Either null or the asset target.
  */
 public function get($name)
 {
     if (!isset($this->indexed[$name])) {
         return null;
     }
     if (empty($this->indexed[$name])) {
         $this->indexed[$name] = $this->factory->target($name);
     }
     return $this->indexed[$name];
 }
Example #3
0
 public function testTargetWithRequireIntegration()
 {
     $requireFile = APP . 'config' . DS . 'require.ini';
     $config = AssetConfig::buildFromIniFile($requireFile);
     $factory = new Factory($config);
     $target = $factory->target('second.js');
     $files = $target->files();
     // Check the top level target
     $this->assertCount(2, $files);
     $middle = $files[0];
     $this->assertInstanceOf('MiniAsset\\File\\Target', $middle);
     $this->assertEquals('middle.js', $middle->name());
     $contents = $middle->contents();
     $this->assertContains('var BaseClass', $contents, 'No baseclass, sprockets not applied');
     $this->assertContains('var Template', $contents);
     $this->assertContains('//= require "local_script"', $contents, 'Sprockets should not be applied to intermediate build files');
 }