diff --git a/.travis.yml b/.travis.yml index cf6641f6..366afb85 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,11 @@ language: php dist: focal +addons: + apt: + packages: + - "libonig5" + matrix: include: - php: 7.4 @@ -37,6 +42,7 @@ before_install: - sudo service elasticsearch restart before_script: + - echo 'date.timezone = "Europe/Warsaw"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/php.ini - phpenv config-rm xdebug.ini - export PATH="$HOME/bin:$PATH" - ./install_composer.sh diff --git a/composer.json b/composer.json index 43d1ef77..bae3bb6a 100644 --- a/composer.json +++ b/composer.json @@ -24,7 +24,7 @@ "doctrine/dbal": "^3.3", "doctrine/doctrine-bundle": "^2.8", "doctrine/orm": "^2.14", - "doctrine/persistence": "^2.3", + "doctrine/persistence": "^2.0|^3.0", "friendsofsymfony/elastica-bundle": "^6.3", "fsi/files": "^2.0|>=2.0.2", "gedmo/doctrine-extensions": "^3.5", diff --git a/tests/Bundle/DataSourceBundle/Fixtures/TestKernel.php b/tests/Bundle/DataSourceBundle/Fixtures/TestKernel.php index bf49dac0..22d07cab 100644 --- a/tests/Bundle/DataSourceBundle/Fixtures/TestKernel.php +++ b/tests/Bundle/DataSourceBundle/Fixtures/TestKernel.php @@ -45,9 +45,14 @@ public function registerBundles(): array ]; } - public function getProjectDir(): string + public function getCacheDir(): string { - return __DIR__; + return "{$this->getProjectDir()}/tests/Bundle/DataSourceBundle/Fixtures/var/cache"; + } + + public function getLogDir(): string + { + return "{$this->getProjectDir()}/tests/Bundle/DataSourceBundle/Fixtures/var/log"; } protected function configureRoutes(RouteCollectionBuilder $routes): void @@ -83,7 +88,7 @@ protected function configureContainer(ContainerBuilder $configuration, LoaderInt 'driver' => 'pdo_sqlite', 'user' => 'admin', 'charset' => 'UTF8', - 'path' => '%kernel.project_dir%/var/data.sqlite', + 'path' => '%kernel.project_dir%/tests/Bundle/DataSourceBundle/Fixtures/var/data.sqlite', 'logging' => false ], 'orm' => [ @@ -93,7 +98,7 @@ protected function configureContainer(ContainerBuilder $configuration, LoaderInt 'datasource_bundle' => [ 'mapping' => true, 'type' => 'xml', - 'dir' => '%kernel.project_dir%/../../../Component/DataSource/Fixtures/doctrine', + 'dir' => '%kernel.project_dir%/tests/Component/DataSource/Fixtures/doctrine', 'prefix' => 'Tests\FSi\Component\DataSource\Fixtures\Entity', 'is_bundle' => false ] diff --git a/tests/Component/DataSource/Driver/Doctrine/DBAL/Fixtures/TestConnectionRegistry.php b/tests/Component/DataSource/Driver/Doctrine/DBAL/Fixtures/TestConnectionRegistry.php index 664b0140..005149a3 100644 --- a/tests/Component/DataSource/Driver/Doctrine/DBAL/Fixtures/TestConnectionRegistry.php +++ b/tests/Component/DataSource/Driver/Doctrine/DBAL/Fixtures/TestConnectionRegistry.php @@ -43,12 +43,12 @@ public function getConnection($name = null): ?\Doctrine\DBAL\Connection public function getConnections(): array { - return [$this->connection]; + return [$this->getDefaultConnectionName() => $this->connection]; } public function getConnectionNames(): array { - return [$this->getDefaultConnectionName()]; + return [$this->getDefaultConnectionName() => $this->getDefaultConnectionName()]; } } } else { @@ -77,12 +77,12 @@ public function getConnection($name = null): ?\Doctrine\DBAL\Driver\Connection public function getConnections(): array { - return [$this->connection]; + return [$this->getDefaultConnectionName() => $this->connection]; } public function getConnectionNames(): array { - return [$this->getDefaultConnectionName()]; + return [$this->getDefaultConnectionName() => $this->getDefaultConnectionName()]; } } } diff --git a/tests/Component/DataSource/Driver/Doctrine/ORM/ORMDriverTest.php b/tests/Component/DataSource/Driver/Doctrine/ORM/ORMDriverTest.php index 76a77b14..5d61cdf5 100644 --- a/tests/Component/DataSource/Driver/Doctrine/ORM/ORMDriverTest.php +++ b/tests/Component/DataSource/Driver/Doctrine/ORM/ORMDriverTest.php @@ -13,14 +13,12 @@ use DateTimeImmutable; use Doctrine\ORM\EntityManager; -use Doctrine\ORM\Mapping\Driver\XmlDriver; +use Doctrine\ORM\Mapping\Driver\SimplifiedXmlDriver; use Doctrine\ORM\Tools\SchemaTool; use Doctrine\ORM\Tools\Setup; use Doctrine\Persistence\ManagerRegistry; -use Doctrine\Persistence\Mapping\Driver\SymfonyFileLocator; use FSi\Component\DataSource\DataSourceFactory; use FSi\Component\DataSource\DataSourceInterface; -use FSi\Component\DataSource\Driver\Doctrine\ORM\ORMFactory; use FSi\Component\DataSource\Driver\Doctrine\ORM\Event\PreGetResult; use FSi\Component\DataSource\Driver\Doctrine\ORM\FieldType\Boolean; use FSi\Component\DataSource\Driver\Doctrine\ORM\FieldType\Date; @@ -29,6 +27,7 @@ use FSi\Component\DataSource\Driver\Doctrine\ORM\FieldType\Number; use FSi\Component\DataSource\Driver\Doctrine\ORM\FieldType\Text; use FSi\Component\DataSource\Driver\Doctrine\ORM\FieldType\Time; +use FSi\Component\DataSource\Driver\Doctrine\ORM\ORMFactory; use FSi\Component\DataSource\Driver\Doctrine\ORM\ORMResult; use FSi\Component\DataSource\Driver\DriverFactoryManager; use FSi\Component\DataSource\Event\PostGetParameters; @@ -55,28 +54,6 @@ final class ORMDriverTest extends TestCase private ?EventDispatcherInterface $eventDispatcher = null; private ?Storage $orderingStorage = null; - protected function setUp(): void - { - $config = Setup::createConfiguration(true, null, null); - $config->setMetadataDriverImpl( - new XmlDriver( - new SymfonyFileLocator( - [__DIR__ . '/../../../Fixtures/doctrine' => 'Tests\FSi\Component\DataSource\Fixtures\Entity'], - '.orm.xml' - ) - ) - ); - $em = EntityManager::create(['driver' => 'pdo_sqlite', 'memory' => true], $config); - $tool = new SchemaTool($em); - $tool->createSchema([ - $em->getClassMetadata(News::class), - $em->getClassMetadata(Category::class), - $em->getClassMetadata(Group::class), - ]); - $this->load($em); - $this->em = $em; - } - public function testNumberFieldComparingWithZero(): void { $dataSourceFactory = $this->getDataSourceFactory(); @@ -176,7 +153,7 @@ public function testGeneralDoctrineDriverConfiguration(): void DataSourceInterface::PARAMETER_FIELDS => [ 'author' => 'domain1.com', 'title' => ['title44', 'title58'], - 'created' => ['from' => new DateTimeImmutable(date('Y:m:d H:i:s', 35 * 24 * 60 * 60))], + 'created' => ['from' => '1970-02-05 01:00:00'], ], ], ]; @@ -699,6 +676,25 @@ public function testCreateDriverWithoutEntityAndQbOptions(): void $factory->createDriver([]); } + protected function setUp(): void + { + $config = Setup::createConfiguration(true, null, null); + $config->setMetadataDriverImpl( + new SimplifiedXmlDriver( + [__DIR__ . '/../../../Fixtures/doctrine' => 'Tests\\FSi\\Component\\DataSource\\Fixtures\\Entity'], + ) + ); + $em = EntityManager::create(['driver' => 'pdo_sqlite', 'memory' => true], $config); + $tool = new SchemaTool($em); + $tool->createSchema([ + $em->getClassMetadata(News::class), + $em->getClassMetadata(Category::class), + $em->getClassMetadata(Group::class), + ]); + $this->load($em); + $this->em = $em; + } + protected function tearDown(): void { $this->eventDispatcher = null; diff --git a/tests/Component/DataSource/FactoryTest.php b/tests/Component/DataSource/FactoryTest.php index 24f1f9b9..f08a45f4 100644 --- a/tests/Component/DataSource/FactoryTest.php +++ b/tests/Component/DataSource/FactoryTest.php @@ -13,14 +13,11 @@ use FSi\Component\DataSource\DataSourceFactory; use FSi\Component\DataSource\Driver\Collection\CollectionFactory; -use FSi\Component\DataSource\Driver\Collection\FieldType\Text; use FSi\Component\DataSource\Driver\DriverFactoryManager; use FSi\Component\DataSource\Exception\DataSourceException; use PHPUnit\Framework\TestCase; use Psr\EventDispatcher\EventDispatcherInterface; -use function array_merge; - final class FactoryTest extends TestCase { public function testFactoryExceptionOnUnknownDriver(): void