Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Closed
Prev Previous commit
Next Next commit
Fix tests
  • Loading branch information
dunglas committed Feb 7, 2017
commit c5ca4bc73729e03f5394b240e95c4005a7df21b0
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bundle\FullStack;
use Symfony\Bundle\FrameworkBundle\Tests\TestCase;
use Symfony\Bundle\FrameworkBundle\DependencyInjection\FrameworkExtension;
use Symfony\Component\Asset\EventListener\PreloadListener;
use Symfony\Component\Cache\Adapter\ApcuAdapter;
use Symfony\Component\Cache\Adapter\ChainAdapter;
use Symfony\Component\Cache\Adapter\DoctrineAdapter;
Expand Down Expand Up @@ -363,8 +364,6 @@ public function testAssets()

$package = $container->getDefinition((string) $packages['bar_version_strategy']);
$this->assertEquals('assets.custom_version_strategy', (string) $package->getArgument(1));

$this->assertTrue($container->hasDefinition('asset.preload_listener'));
}

public function testAssetsDefaultVersionStrategyAsService()
Expand All @@ -377,6 +376,16 @@ public function testAssetsDefaultVersionStrategyAsService()
$this->assertEquals('assets.custom_version_strategy', (string) $defaultPackage->getArgument(1));
}

public function testAssetHasPreloadListener()
{
if (!class_exists(PreloadListener::class)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

composer ensures that this is always existing

Copy link
Member Author

@dunglas dunglas Feb 1, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not if a version for symfony/asset lesser than 3.3 has been installed, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it cannot, due to the require-dev constraint

$this->markTestSkipped('Requires asset 3.3 or superior.');
}

$container = $this->createContainerFromFile('assets');
$this->assertTrue($container->hasDefinition('asset.preload_listener'));
}

public function testTranslator()
{
$container = $this->createContainerFromFile('full');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function testOnKernelResponse()
$listener = new PreloadListener($manager);
$response = new Response();

$event = $this->createMock(FilterResponseEvent::class);
$event = $this->getMockBuilder(FilterResponseEvent::class)->disableOriginalConstructor()->getMock();
$event->method('getResponse')->willReturn($response);

$listener->onKernelResponse($event);
Expand Down
2 changes: 1 addition & 1 deletion src/Symfony/Component/Asset/Tests/PackageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public function testGetVersion()

public function testGetAndPreloadUrl()
{
$preloadManager = $this->createMock(PreloadManagerInterface::class);
$preloadManager = $this->getMockBuilder(PreloadManagerInterface::class)->getMock();
$preloadManager
->expects($this->exactly(2))
->method('addResource')
Expand Down
4 changes: 2 additions & 2 deletions src/Symfony/Component/Asset/Tests/PackagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function testGetUrl()

public function testGetAndPreloadUrl()
{
$preloadManager = $this->createMock(PreloadManagerInterface::class);
$preloadManager = $this->getMockBuilder(PreloadManagerInterface::class)->getMock();
$preloadManager
->expects($this->exactly(2))
->method('addResource')
Expand Down Expand Up @@ -100,7 +100,7 @@ public function testUndefinedPackage()
*/
public function testDoesNotSupportPreloading()
{
$packages = new Packages($this->createMock(PackageInterface::class));
$packages = new Packages($this->getMockBuilder(PackageInterface::class)->getMock());
$packages->getAndPreloadUrl('/foo');
}
}