diff --git a/Binary/Locator/FileSystemLocator.php b/Binary/Locator/FileSystemLocator.php
index 1cff51d92..09897f3af 100644
--- a/Binary/Locator/FileSystemLocator.php
+++ b/Binary/Locator/FileSystemLocator.php
@@ -21,7 +21,7 @@ class FileSystemLocator implements LocatorInterface
/**
* @var string[]
*/
- protected $roots;
+ private $roots;
/**
* @param array[] $options
diff --git a/DependencyInjection/Compiler/LocatorsCompilerPass.php b/DependencyInjection/Compiler/LocatorsCompilerPass.php
new file mode 100644
index 000000000..03824c33e
--- /dev/null
+++ b/DependencyInjection/Compiler/LocatorsCompilerPass.php
@@ -0,0 +1,41 @@
+findTaggedServiceIds('liip_imagine.binary.locator')) as $id) {
+ $this->disableSharedDefinition($container->getDefinition($id));
+ }
+ }
+
+ /**
+ * @param Definition $definition
+ */
+ private function disableSharedDefinition(Definition $definition)
+ {
+ if (SymfonyFramework::hasDefinitionSharedToggle()) {
+ $definition->setShared(false);
+ } else {
+ $definition->setScope('prototype');
+ }
+ }
+}
diff --git a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php
index ae5f198ba..1c77c8c29 100644
--- a/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php
+++ b/DependencyInjection/Factory/Loader/FileSystemLoaderFactory.php
@@ -11,8 +11,10 @@
namespace Liip\ImagineBundle\DependencyInjection\Factory\Loader;
+use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
+use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Reference;
class FileSystemLoaderFactory extends AbstractLoaderFactory
@@ -24,7 +26,7 @@ public function create(ContainerBuilder $container, $loaderName, array $config)
{
$definition = $this->getChildLoaderDefinition();
$definition->replaceArgument(2, $config['data_root']);
- $definition->replaceArgument(3, new Reference(sprintf('liip_imagine.binary.locator.%s', $config['locator'])));
+ $definition->replaceArgument(3, $this->createLocatorReference($config['locator']));
return $this->setTaggedLoaderDefinition($loaderName, $definition, $container);
}
@@ -61,4 +63,18 @@ public function addConfiguration(ArrayNodeDefinition $builder)
->end()
->end();
}
+
+ /**
+ * @param string $reference
+ *
+ * @return Reference
+ */
+ private function createLocatorReference($reference)
+ {
+ return new Reference(
+ sprintf('liip_imagine.binary.locator.%s', $reference),
+ ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE,
+ SymfonyFramework::hasDefinitionSharedToggle()
+ );
+ }
}
diff --git a/LiipImagineBundle.php b/LiipImagineBundle.php
index 31e616aa3..acc0f5f6e 100644
--- a/LiipImagineBundle.php
+++ b/LiipImagineBundle.php
@@ -13,6 +13,7 @@
use Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass;
use Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass;
+use Liip\ImagineBundle\DependencyInjection\Compiler\LocatorsCompilerPass;
use Liip\ImagineBundle\DependencyInjection\Compiler\MetadataReaderCompilerPass;
use Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass;
use Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass;
@@ -35,6 +36,7 @@ public function build(ContainerBuilder $container)
{
parent::build($container);
+ $container->addCompilerPass(new LocatorsCompilerPass());
$container->addCompilerPass(new LoadersCompilerPass());
$container->addCompilerPass(new FiltersCompilerPass());
$container->addCompilerPass(new PostProcessorsCompilerPass());
diff --git a/Resources/config/imagine.xml b/Resources/config/imagine.xml
index a011adbd7..09e788ca2 100644
--- a/Resources/config/imagine.xml
+++ b/Resources/config/imagine.xml
@@ -247,9 +247,11 @@
+
+
diff --git a/Tests/DependencyInjection/Compiler/LocatorsCompilerPassTest.php b/Tests/DependencyInjection/Compiler/LocatorsCompilerPassTest.php
new file mode 100644
index 000000000..cd805a133
--- /dev/null
+++ b/Tests/DependencyInjection/Compiler/LocatorsCompilerPassTest.php
@@ -0,0 +1,51 @@
+addTag('liip_imagine.binary.locator', array(
+ 'shared' => true,
+ ));
+
+ $container = new ContainerBuilder();
+ $container->setDefinition('liip_imagine.binary.locator.foo', $locatorDefinition);
+
+ $pass = new LocatorsCompilerPass();
+
+ //guard
+ if (method_exists($locatorDefinition, 'isShared')) {
+ $this->assertTrue($locatorDefinition->isShared());
+ } else {
+ $this->assertSame('container', $locatorDefinition->getScope());
+ }
+
+ $pass->process($container);
+
+ if (method_exists($locatorDefinition, 'isShared')) {
+ $this->assertFalse($locatorDefinition->isShared());
+ } else {
+ $this->assertSame('prototype', $locatorDefinition->getScope());
+ }
+ }
+}
diff --git a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php
index 0ff5284a1..cb1ea52bc 100644
--- a/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php
+++ b/Tests/DependencyInjection/Factory/Resolver/AwsS3ResolverFactoryTest.php
@@ -12,13 +12,13 @@
namespace Liip\ImagineBundle\Tests\DependencyInjection\Factory\Resolver;
use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory;
+use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\DependencyInjection\ContainerBuilder;
-use Symfony\Component\HttpKernel\Kernel;
/**
- * @covers Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory
+ * @covers \Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory
*/
class AwsS3ResolverFactoryTest extends \Phpunit_Framework_TestCase
{
@@ -122,7 +122,7 @@ public function testCreateS3ClientDefinitionOnCreate()
public function testCreateS3ClientDefinitionWithFactoryOnCreate()
{
- if (version_compare(Kernel::VERSION_ID, '20600') < 0) {
+ if (SymfonyFramework::isKernelLessThan(2, 6)) {
$this->markTestSkipped('No need to test on symfony < 2.6');
}
@@ -147,7 +147,7 @@ public function testCreateS3ClientDefinitionWithFactoryOnCreate()
public function testLegacyCreateS3ClientDefinitionWithFactoryOnCreate()
{
- if (version_compare(Kernel::VERSION_ID, '20600') >= 0) {
+ if (SymfonyFramework::isKernelGreaterThanOrEqualTo(2, 6)) {
$this->markTestSkipped('No need to test on symfony >= 2.6');
}
diff --git a/Tests/DependencyInjection/LiipImagineExtensionTest.php b/Tests/DependencyInjection/LiipImagineExtensionTest.php
index 3fe056d7c..07b1350f8 100644
--- a/Tests/DependencyInjection/LiipImagineExtensionTest.php
+++ b/Tests/DependencyInjection/LiipImagineExtensionTest.php
@@ -15,15 +15,16 @@
use Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory;
use Liip\ImagineBundle\DependencyInjection\LiipImagineExtension;
use Liip\ImagineBundle\Tests\AbstractTest;
+use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
+use Symfony\Component\DependencyInjection\Definition;
use Symfony\Component\DependencyInjection\Reference;
-use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\Yaml\Parser;
/**
- * @covers Liip\ImagineBundle\DependencyInjection\Configuration
- * @covers Liip\ImagineBundle\DependencyInjection\LiipImagineExtension
+ * @covers \Liip\ImagineBundle\DependencyInjection\Configuration
+ * @covers \Liip\ImagineBundle\DependencyInjection\LiipImagineExtension
*/
class LiipImagineExtensionTest extends AbstractTest
{
@@ -77,7 +78,7 @@ public function testCustomRouteRequirements()
*/
public function testFactoriesConfiguration($service, $factory)
{
- if (version_compare(Kernel::VERSION_ID, '20600') < 0) {
+ if (SymfonyFramework::isKernelLessThan(2, 6)) {
$this->markTestSkipped('No need to test on symfony < 2.6');
}
@@ -88,11 +89,12 @@ public function testFactoriesConfiguration($service, $factory)
}
/**
+ * @legacy
* @dataProvider factoriesProvider
*/
public function testLegacyFactoriesConfiguration($service, $factory)
{
- if (version_compare(Kernel::VERSION_ID, '20600') >= 0) {
+ if (SymfonyFramework::isKernelGreaterThanOrEqualTo(2, 6)) {
$this->markTestSkipped('No need to test on symfony >= 2.6');
}
@@ -117,9 +119,6 @@ public function factoriesProvider()
);
}
- /**
- * @return ContainerBuilder
- */
protected function createEmptyConfiguration()
{
$this->containerBuilder = new ContainerBuilder();
@@ -130,9 +129,6 @@ protected function createEmptyConfiguration()
$this->assertTrue($this->containerBuilder instanceof ContainerBuilder);
}
- /**
- * @return ContainerBuilder
- */
protected function createFullConfiguration()
{
$this->containerBuilder = new ContainerBuilder();
@@ -183,29 +179,39 @@ protected function getFullConfig()
return $parser->parse($yaml);
}
+ /**
+ * @param string $value
+ * @param string $key
+ */
private function assertAlias($value, $key)
{
$this->assertEquals($value, (string) $this->containerBuilder->getAlias($key), sprintf('%s alias is correct', $key));
}
+ /**
+ * @param string $value
+ * @param string $key
+ */
private function assertParameter($value, $key)
{
$this->assertEquals($value, $this->containerBuilder->getParameter($key), sprintf('%s parameter is correct', $key));
}
+ /**
+ * @param string $id
+ */
private function assertHasDefinition($id)
{
$this->assertTrue(($this->containerBuilder->hasDefinition($id) ?: $this->containerBuilder->hasAlias($id)));
}
- private function assertNotHasDefinition($id)
- {
- $this->assertFalse(($this->containerBuilder->hasDefinition($id) ?: $this->containerBuilder->hasAlias($id)));
- }
-
- private function assertDICConstructorArguments($definition, $args)
+ /**
+ * @param Definition $definition
+ * @param array $arguments
+ */
+ private function assertDICConstructorArguments(Definition $definition, array $arguments)
{
- $this->assertEquals($args, $definition->getArguments(), "Expected and actual DIC Service constructor arguments of definition '".$definition->getClass()."' don't match.");
+ $this->assertEquals($arguments, $definition->getArguments(), "Expected and actual DIC Service constructor arguments of definition '".$definition->getClass()."' don't match.");
}
protected function tearDown()
diff --git a/Tests/Form/Type/ImageTypeTest.php b/Tests/Form/Type/ImageTypeTest.php
index 19481a684..37c543cee 100644
--- a/Tests/Form/Type/ImageTypeTest.php
+++ b/Tests/Form/Type/ImageTypeTest.php
@@ -12,12 +12,12 @@
namespace Liip\ImagineBundle\Tests\Form\Type;
use Liip\ImagineBundle\Form\Type\ImageType;
+use Liip\ImagineBundle\Utility\Framework\SymfonyFramework;
use Symfony\Component\Form\FormView;
-use Symfony\Component\HttpKernel\Kernel;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
- * @covers Liip\ImagineBundle\Form\Type\ImageType
+ * @covers \Liip\ImagineBundle\Form\Type\ImageType
*/
class ImageTypeTest extends \PHPUnit_Framework_TestCase
{
@@ -37,7 +37,7 @@ public function testGetParent()
public function testConfigureOptions()
{
- if (version_compare(Kernel::VERSION_ID, '20600') < 0) {
+ if (SymfonyFramework::isKernelLessThan(2, 6)) {
$this->markTestSkipped('No need to test on symfony < 2.6');
}
@@ -57,7 +57,7 @@ public function testConfigureOptions()
public function testLegacySetDefaultOptions()
{
- if (version_compare(Kernel::VERSION_ID, '20600') >= 0) {
+ if (SymfonyFramework::isKernelGreaterThanOrEqualTo(2, 6)) {
$this->markTestSkipped('No need to test on symfony >= 2.6');
}
diff --git a/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php
new file mode 100644
index 000000000..5abbf1839
--- /dev/null
+++ b/Tests/Functional/Binary/Loader/FileSystemLoaderTest.php
@@ -0,0 +1,60 @@
+getService(sprintf('liip_imagine.binary.loader.%s', $name));
+ }
+
+ private function getPrivateProperty($object, $name)
+ {
+ $r = new \ReflectionObject($object);
+
+ $p = $r->getProperty($name);
+ $p->setAccessible(true);
+
+ return $p->getValue($object);
+ }
+
+ public function testMultipleLoadersContainIndependentLocators()
+ {
+ $fooLoader = $this->getLoader('foo');
+ $barLoader = $this->getLoader('bar');
+
+ $fooLocator = $this->getPrivateProperty($fooLoader, 'locator');
+ $barLocator = $this->getPrivateProperty($barLoader, 'locator');
+
+ $this->assertNotSame($fooLocator, $barLocator);
+
+ $fooRoots = $this->getPrivateProperty($fooLocator, 'roots');
+ $barRoots = $this->getPrivateProperty($barLocator, 'roots');
+
+ $this->assertNotSame($fooRoots, $barRoots);
+
+ $this->assertStringEndsWith('root-01', $fooRoots[0]);
+ $this->assertStringEndsWith('root-02', $barRoots[0]);
+ }
+}
diff --git a/Tests/Functional/WebTestCase.php b/Tests/Functional/WebTestCase.php
index efe217d67..d75453a99 100644
--- a/Tests/Functional/WebTestCase.php
+++ b/Tests/Functional/WebTestCase.php
@@ -24,4 +24,32 @@ public static function getKernelClass()
return 'Liip\ImagineBundle\Tests\Functional\app\AppKernel';
}
+
+ /**
+ * @param string $name
+ *
+ * @return object
+ */
+ protected function getService($name)
+ {
+ if (!static::$kernel) {
+ $this->createClient();
+ }
+
+ return static::$kernel->getContainer()->get($name);
+ }
+
+ /**
+ * @param string $name
+ *
+ * @return mixed
+ */
+ protected function getParameter($name)
+ {
+ if (!static::$kernel) {
+ $this->createClient();
+ }
+
+ return static::$kernel->getContainer()->getParameter($name);
+ }
}
diff --git a/Tests/Functional/app/config/config.yml b/Tests/Functional/app/config/config.yml
index af7b4dfc5..ab8605137 100644
--- a/Tests/Functional/app/config/config.yml
+++ b/Tests/Functional/app/config/config.yml
@@ -19,6 +19,12 @@ liip_imagine:
default:
filesystem:
data_root: "%kernel.root_dir%/web"
+ foo:
+ filesystem:
+ data_root: "%kernel.root_dir%/../../Fixtures/FileSystemLocator/root-01"
+ bar:
+ filesystem:
+ data_root: "%kernel.root_dir%/../../Fixtures/FileSystemLocator/root-02"
resolvers:
default:
web_path:
diff --git a/Tests/LiipImagineBundleTest.php b/Tests/LiipImagineBundleTest.php
index aa69a3882..70a7c4606 100644
--- a/Tests/LiipImagineBundleTest.php
+++ b/Tests/LiipImagineBundleTest.php
@@ -12,10 +12,9 @@
namespace Liip\ImagineBundle\Tests;
use Liip\ImagineBundle\LiipImagineBundle;
-use Symfony\Component\DependencyInjection\ContainerBuilder;
/**
- * @covers Liip\ImagineBundle\LiipImagineBundle
+ * @covers \Liip\ImagineBundle\LiipImagineBundle
*/
class LiipImagineBundleTest extends \Phpunit_Framework_TestCase
{
@@ -24,85 +23,88 @@ public function testSubClassOfBundle()
$this->assertInstanceOf('Symfony\Component\HttpKernel\Bundle\Bundle', new LiipImagineBundle());
}
- public function testAddLoadersCompilerPassOnBuild()
+ public function testLocatorsCompilerPassOnBuild()
{
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($this->createExtensionMock()))
- ;
+ ->will($this->returnValue($this->createExtensionMock()));
$containerMock
->expects($this->at(0))
->method('addCompilerPass')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass'))
- ;
-
- $container = new ContainerBuilder();
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\LocatorsCompilerPass'));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
- public function testAddFiltersCompilerPassOnBuild()
+ public function testAddLoadersCompilerPassOnBuild()
{
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($this->createExtensionMock()))
- ;
+ ->will($this->returnValue($this->createExtensionMock()));
$containerMock
->expects($this->at(1))
->method('addCompilerPass')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\LoadersCompilerPass'));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
- public function testAddPostProcessorsCompilerPassOnBuild()
+ public function testAddFiltersCompilerPassOnBuild()
{
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($this->createExtensionMock()))
- ;
+ ->will($this->returnValue($this->createExtensionMock()));
$containerMock
->expects($this->at(2))
->method('addCompilerPass')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\FiltersCompilerPass'));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
- public function testAddResolversCompilerPassOnBuild()
+ public function testAddPostProcessorsCompilerPassOnBuild()
{
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($this->createExtensionMock()))
- ;
+ ->will($this->returnValue($this->createExtensionMock()));
$containerMock
->expects($this->at(3))
->method('addCompilerPass')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\PostProcessorsCompilerPass'));
$bundle = new LiipImagineBundle();
+ $bundle->build($containerMock);
+ }
+ public function testAddResolversCompilerPassOnBuild()
+ {
+ $containerMock = $this->createContainerBuilderMock();
+ $containerMock
+ ->expects($this->atLeastOnce())
+ ->method('getExtension')
+ ->with('liip_imagine')
+ ->will($this->returnValue($this->createExtensionMock()));
+ $containerMock
+ ->expects($this->at(4))
+ ->method('addCompilerPass')
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Compiler\ResolversCompilerPass'));
+
+ $bundle = new LiipImagineBundle();
$bundle->build($containerMock);
}
@@ -112,19 +114,16 @@ public function testAddWebPathResolverFactoryOnBuild()
$extensionMock
->expects($this->at(0))
->method('addResolverFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\WebPathResolverFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -134,19 +133,16 @@ public function testAddAwsS3ResolverFactoryOnBuild()
$extensionMock
->expects($this->at(1))
->method('addResolverFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\AwsS3ResolverFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -156,19 +152,16 @@ public function testAddFlysystemResolverFactoryOnBuild()
$extensionMock
->expects($this->at(2))
->method('addResolverFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\FlysystemResolverFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Resolver\FlysystemResolverFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -178,19 +171,16 @@ public function testAddStreamLoaderFactoryOnBuild()
$extensionMock
->expects($this->at(3))
->method('addLoaderFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\StreamLoaderFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\StreamLoaderFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -200,19 +190,16 @@ public function testAddFilesystemLoaderFactoryOnBuild()
$extensionMock
->expects($this->at(4))
->method('addLoaderFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\FilesystemLoaderFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\FilesystemLoaderFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -222,19 +209,16 @@ public function testAddFlysystemLoaderFactoryOnBuild()
$extensionMock
->expects($this->at(5))
->method('addLoaderFactory')
- ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\FlysystemLoaderFactory'))
- ;
+ ->with($this->isInstanceOf('Liip\ImagineBundle\DependencyInjection\Factory\Loader\FlysystemLoaderFactory'));
$containerMock = $this->createContainerBuilderMock();
$containerMock
->expects($this->atLeastOnce())
->method('getExtension')
->with('liip_imagine')
- ->will($this->returnValue($extensionMock))
- ;
+ ->will($this->returnValue($extensionMock));
$bundle = new LiipImagineBundle();
-
$bundle->build($containerMock);
}
@@ -246,7 +230,9 @@ protected function createContainerBuilderMock()
protected function createExtensionMock()
{
$methods = array(
- 'getNamespace', 'addResolverFactory', 'addLoaderFactory',
+ 'getNamespace',
+ 'addResolverFactory',
+ 'addLoaderFactory',
);
return $this->getMock('Liip\ImagineBundle\DependencyInjection\LiipImagineExtension', $methods, array(), '', false);
diff --git a/Utility/Framework/SymfonyFramework.php b/Utility/Framework/SymfonyFramework.php
new file mode 100644
index 000000000..25656f78c
--- /dev/null
+++ b/Utility/Framework/SymfonyFramework.php
@@ -0,0 +1,75 @@
+=', $major, $minor, $patch);
+ }
+
+ /**
+ * @param int $major
+ * @param int|null $minor
+ * @param int|null $patch
+ *
+ * @return bool
+ */
+ public static function isKernelLessThan($major, $minor = null, $patch = null)
+ {
+ return static::kernelVersionCompare('<', $major, $minor, $patch);
+ }
+
+ /**
+ * @param string $operator
+ * @param int $major
+ * @param int|null $minor
+ * @param int|null $patch
+ *
+ * @return bool
+ */
+ private static function kernelVersionCompare($operator, $major, $minor = null, $patch = null)
+ {
+ $vernum = $major;
+ $kernel = Kernel::MAJOR_VERSION;
+
+ if ($minor) {
+ $vernum .= '.'.$minor;
+ $kernel .= '.'.Kernel::MINOR_VERSION;
+
+ if ($patch) {
+ $vernum .= '.'.$patch;
+ $kernel .= '.'.Kernel::RELEASE_VERSION;
+ }
+ }
+
+ return version_compare($kernel, $vernum, $operator);
+ }
+}