diff --git a/Loader/AbstractLoader.php b/Loader/AbstractLoader.php index acf6fcd..e423f39 100644 --- a/Loader/AbstractLoader.php +++ b/Loader/AbstractLoader.php @@ -2,7 +2,7 @@ namespace Lexik\Bundle\FixturesMapperBundle\Loader; -use Symfony\Component\Validator\Validator; +use Symfony\Component\Validator\Validator\ValidatorInterface; /** * Base loader class for fixtures. @@ -40,11 +40,11 @@ abstract class AbstractLoader * Constructor. * * @param EntityManager $entityManager - * @param Validator $validator + * @param ValidatorInterface $validator * @param string $mapperClass * @param string $mapperCollectionDelimiter */ - public function __construct($entityManager, array $adapters, Validator $validator, $mapperClass, $mapperCollectionDelimiter) + public function __construct($entityManager, array $adapters, ValidatorInterface $validator, $mapperClass, $mapperCollectionDelimiter) { $this->adapters = $adapters; $this->validator = $validator; diff --git a/Mapper/Mapper.php b/Mapper/Mapper.php index c1d9b32..1531f82 100644 --- a/Mapper/Mapper.php +++ b/Mapper/Mapper.php @@ -7,7 +7,7 @@ use Lexik\Bundle\FixturesMapperBundle\Adapter\EntityManagerAdapterInterface; use Lexik\Bundle\FixturesMapperBundle\Exception\InvalidMethodException; -use Symfony\Component\Validator\Validator; +use Symfony\Component\Validator\Validator\ValidatorInterface; use Symfony\Component\DependencyInjection\Container; /** @@ -94,9 +94,9 @@ class Mapper implements MapperInterface * * @param array $values * @param EntityManagerAdapterInterface $entityManager - * @param Validator $validator + * @param ValidatorInterface $validator */ - public function __construct(array $values, EntityManagerAdapterInterface $entityManager, Validator $validator, $collectionDelimiter) + public function __construct(array $values, EntityManagerAdapterInterface $entityManager, ValidatorInterface $validator, $collectionDelimiter) { $this->values = $values; $this->entityManager = $entityManager; diff --git a/Tests/Loader/CsvLoaderTest.php b/Tests/Loader/CsvLoaderTest.php index 7526953..8cd6c99 100644 --- a/Tests/Loader/CsvLoaderTest.php +++ b/Tests/Loader/CsvLoaderTest.php @@ -6,6 +6,7 @@ use Lexik\Bundle\FixturesMapperBundle\Loader\CsvLoader; use Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper; +use Symfony\Component\Validator\Validation; use Symfony\Component\Validator\ValidatorFactory; class CsvLoaderTest extends TestCase @@ -23,7 +24,8 @@ protected function setUp() ), ); - $validator = ValidatorFactory::buildDefault(array(), true)->getValidator(); + $validator = Validation::createValidatorBuilder() + ->getValidator(); $this->csvLoader = new CsvLoader($this->getMockSqliteEntityManager(), $adapters, $validator, 'Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper', '|'); } diff --git a/Tests/Loader/YamlLoaderTest.php b/Tests/Loader/YamlLoaderTest.php index fead9e5..f8e67f0 100644 --- a/Tests/Loader/YamlLoaderTest.php +++ b/Tests/Loader/YamlLoaderTest.php @@ -6,7 +6,7 @@ use Lexik\Bundle\FixturesMapperBundle\Loader\YamlLoader; use Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper; -use Symfony\Component\Validator\ValidatorFactory; +use Symfony\Component\Validator\Validation; class YamlLoaderTest extends TestCase { @@ -23,7 +23,8 @@ protected function setUp() ), ); - $validator = ValidatorFactory::buildDefault(array(), true)->getValidator(); + $validator = Validation::createValidatorBuilder() + ->getValidator(); $this->yamlLoader = new YamlLoader($this->getMockSqliteEntityManager(), $adapters, $validator, 'Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper', '|'); } diff --git a/Tests/Mapper/MapperTest.php b/Tests/Mapper/MapperTest.php index d50eeb1..7118953 100644 --- a/Tests/Mapper/MapperTest.php +++ b/Tests/Mapper/MapperTest.php @@ -8,7 +8,8 @@ use Lexik\Bundle\FixturesMapperBundle\Loader\YamlLoader; use Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper; -use Symfony\Component\Validator\ValidatorFactory; +use Symfony\Component\Validator\Validation; +use Doctrine\DBAL\DBALException; class MapperTest extends TestCase { @@ -31,7 +32,8 @@ protected function setUp() ), ); - $this->validator = ValidatorFactory::buildDefault(array(), true)->getValidator(); + $this->validator = Validation::createValidatorBuilder() + ->getValidator(); $this->csvLoader = new CsvLoader($this->em, $adapters, $this->validator, 'Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper', '|'); $this->yamlLoader = new YamlLoader($this->em, $adapters, $this->validator, 'Lexik\Bundle\FixturesMapperBundle\Mapper\Mapper', '|'); @@ -92,7 +94,7 @@ public function testFromYaml() } /** - * @expectedException PDOException + * @expectedException Doctrine\DBAL\DBALException * @expectedExceptionMessage Article.title may not be NULL */ public function testFromYamlIncompleteMapping() diff --git a/Tests/TestCase.php b/Tests/TestCase.php index 9493177..7d999d0 100644 --- a/Tests/TestCase.php +++ b/Tests/TestCase.php @@ -2,6 +2,7 @@ namespace Lexik\Bundle\FixturesMapperBundle\Tests; +use Doctrine\ORM\Repository\DefaultRepositoryFactory; use Symfony\Component\DependencyInjection\ContainerBuilder; use Doctrine\Common\Annotations\AnnotationReader; use Doctrine\ORM\EntityManager; @@ -54,7 +55,6 @@ protected function getMockSqliteEntityManager() $reader = new AnnotationReader(); $mappingDriver = new AnnotationDriverORM($reader, array( - __DIR__.'/../vendor/doctrine/lib', __DIR__.'/Fixture/Entity', )); @@ -79,10 +79,19 @@ protected function getMockSqliteEntityManager() ->method('getMetadataDriverImpl') ->will($this->returnValue($mappingDriver)); - $config->expects($this->any()) - ->method('getDefaultRepositoryClassName') + $config->expects($this->any()) + ->method('getDefaultRepositoryClassName') ->will($this->returnValue('Doctrine\\ORM\\EntityRepository')); + $config->expects($this->any()) + ->method('getQuoteStrategy') + ->will($this->returnValue( new Mapping\DefaultQuoteStrategy())); + + + $config->expects($this->any()) + ->method('getRepositoryFactory') + ->will($this->returnValue( new DefaultRepositoryFactory())); + $evm = $this->getMock('Doctrine\Common\EventManager'); $em = \Doctrine\ORM\EntityManager::create($conn, $config, $evm); diff --git a/autoload.php.dist b/autoload.php.dist index 8283af3..8094dbf 100644 --- a/autoload.php.dist +++ b/autoload.php.dist @@ -1,6 +1,6 @@ registerNamespaces(array( )); if (!function_exists('intl_get_error_code')) { - require_once __DIR__.'/vendor/symfony/src/Symfony/Component/Locale/Resources/stubs/functions.php'; - $loader->registerPrefixFallbacks(array(__DIR__.'/vendor/symfony/src/Symfony/Component/Locale/Resources/stubs')); + require_once __DIR__.'/vendor/symfony/symfony/src/Symfony/Component/Intl/Resources/stubs/functions.php'; + $loader->registerPrefixFallbacks(array(__DIR__.'/vendor/symfony/symfony/src/Symfony/Component/Locale/Resources/stubs')); } $loader->register(); -AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); +AnnotationRegistry::registerFile(__DIR__.'/vendor/doctrine/orm/lib/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php'); spl_autoload_register(function($class) { $class = ltrim($class, '\\'); @@ -32,4 +32,4 @@ spl_autoload_register(function($class) { require $file; } } -}); +}); \ No newline at end of file diff --git a/composer.json b/composer.json index e83e42b..c805d50 100644 --- a/composer.json +++ b/composer.json @@ -17,11 +17,13 @@ ], "require": { "php": ">=5.3.2", - "symfony/symfony": "~2.1" + "symfony/symfony": "~2.5" }, - "suggest": { - "doctrine/data-fixtures": "*", - "doctrine/orm": "*" + "require-dev": { + "phpunit/phpunit": "3.7.*", + "doctrine/data-fixtures": "*", + "doctrine/orm": "*" + }, "autoload": { "psr-0": { "Lexik\\Bundle\\FixturesMapperBundle": "" }