1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
<?php
/*
* This file is part of the Symfony WebpackEncoreBundle package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\WebpackEncoreBundle\Tests\Asset;
use PHPUnit\Framework\TestCase;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupCollection;
use Symfony\WebpackEncoreBundle\Asset\EntrypointLookupInterface;
class EntrypointLookupCollectionTest extends TestCase
{
public function testExceptionOnMissingEntry()
{
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException::class);
$this->expectExceptionMessage('The build "something" is not configured');
$collection = new EntrypointLookupCollection(new ServiceLocator([]));
$collection->getEntrypointLookup('something');
}
public function testExceptionOnMissingDefaultBuildEntry()
{
$this->expectException(\Symfony\WebpackEncoreBundle\Exception\UndefinedBuildException::class);
$this->expectExceptionMessage('There is no default build configured: please pass an argument to getEntrypointLookup().');
$collection = new EntrypointLookupCollection(new ServiceLocator([]));
$collection->getEntrypointLookup();
}
public function testDefaultBuildIsReturned()
{
$lookup = $this->createMock(EntrypointLookupInterface::class);
$collection = new EntrypointLookupCollection(new ServiceLocator(['the_default' => function () use ($lookup) { return $lookup; }]), 'the_default');
$this->assertSame($lookup, $collection->getEntrypointLookup());
}
}
|