public function testFacade() { $provider = new LassetServiceProvider($this->app); $provider->boot(); $provider->register(); $manager = new Manager($this->getConfig()); $manager->setDefault('production'); $this->app->shouldReceive('offsetGet')->once()->with(LassetServiceProvider::MANAGER_KEY)->andReturn($manager); Lasset::setFacadeApplication($this->app); $this->assertEquals('http://static.example.org/foobar', Lasset::url('foobar')); }
protected function bindLasset(Container $app) { // Load default config from /config/config.php $app['config']->package('rmasters/lasset', __DIR__ . '/../config'); $app->bindShared(self::MANAGER_KEY, function ($app) { $manager = new Manager($app['config']->get('lasset')); if (is_null($manager->getDefault()) && $manager->hasEnvironment($app['env'])) { $manager->setDefault($app['env']); } return $manager; }); }
public function testConfigure() { $lasset = new Manager(); $lasset->configure(array('environments' => array('local' => array('provider' => 'Lasset\\Providers\\Host', 'options' => array('baseUrl' => '/components'))))); $this->assertInstanceOf('Lasset\\Providers\\Host', $lasset->getProvider('local')); $this->assertEquals('/components/foobar', $lasset->getProvider('local')->url('foobar')); $lasset->configure(array('environments' => array('testing' => 'StubProvider'))); $this->assertInstanceOf('StubProvider', $lasset->getProvider('testing')); $this->setExpectedException('InvalidArgumentException', 'Lasset config for environment broken1, provider must implement Lasset\\Providers\\ProviderInterface'); $lasset->configure(array('environments' => array('broken1' => new \stdclass()))); $this->setExpectedException('InvalidArgumentException', 'Lasset config for environment broken2, provider must implement Lasset\\Providers\\ProviderInterface'); $lasset->configure(array('environments' => array('broken2' => 'ArrayObject'))); $this->setExpectedException('InvalidArgumentException', 'Lasset config for environment broken3 expects either an array or a provider'); $lasset->configure(array('environments' => array('broken3' => 123))); $this->setExpectedException('InvalidArgumentException', 'Lasset config for environment broken4 must contain a \'provider\' class name'); $lasset->configure(array('environments' => array('broken4' => array('options' => array())))); }