Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow doctrine/orm 3, doctrine/dbal 4 (WIP) #265

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
158 changes: 79 additions & 79 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,83 +1,83 @@
{
"name": "liip/test-fixtures-bundle",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please restore the original indentation or do this change in another PR.

"description": "This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications",
"keywords": ["symfony", "testing", "fixtures"],
"type": "symfony-bundle",
"license": "MIT",
"authors": [
{
"name": "Liip AG",
"homepage": "http://www.liip.ch/"
},
{
"name": "Community contributions",
"homepage": "https://github.com/liip/LiipTestFixturesBundle/contributors"
}
],
"require": {
"php": "^7.4 || ^8.0",
"doctrine/common": "^2.13 || ^3.0",
"doctrine/persistence": "^1.3.3 || ^2.0 || ^3.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/event-dispatcher": "^5.4 || ^6.3 || ^7.0",
"symfony/event-dispatcher-contracts": "^1 || ^2 || ^3",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/yaml": "^5.4 || ^6.3 || ^7.0"
"name": "liip/test-fixtures-bundle",
"description": "This bundles enables efficient loading of Doctrine fixtures in functional test-cases for Symfony applications",
"keywords": ["symfony", "testing", "fixtures"],
"type": "symfony-bundle",
"license": "MIT",
"authors": [
{
"name": "Liip AG",
"homepage": "http://www.liip.ch/"
},
"require-dev": {
"doctrine/annotations": "^1.13.1 || ^2.0",
"doctrine/data-fixtures": "^1.4.4",
"doctrine/dbal": "^2.13.1 || ^3.1",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0",
"doctrine/mongodb-odm": "^2.2",
"doctrine/mongodb-odm-bundle": "^4.2.1 || ^5.0",
"doctrine/orm": "^2.14 || ^3.0",
"doctrine/phpcr-bundle": "^2.4.3 || ^3.0",
"doctrine/phpcr-odm": "^1.7.2 || ^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.10.1 || ^2.0",
"monolog/monolog": "^1.25.1 || ^2.0 || ^3.0",
"phpunit/phpunit": "^9.6.17 || ^10.5.11 || ^11.0.4",
"symfony/doctrine-bridge": "^5.4 || ^6.3 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.3 || ^7.0",
"symfony/monolog-bundle": "^3.2",
"symfony/phpunit-bridge": "^7.0",
"theofidry/alice-data-fixtures": "^1.5.2"
},
"conflict": {
"doctrine/annotations": "<1.13.1 || >=3.0",
"doctrine/dbal": "<2.13.1 || ~3.0.0 || >=4.0",
"doctrine/mongodb-odm": "<2.2 || >=3.0",
"doctrine/orm": "<2.14 || >=4.0"
},
"suggest": {
"doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite",
"doctrine/doctrine-fixtures-bundle": "Required when using the fixture loading functionality",
"doctrine/orm": "Required when using the fixture loading functionality with an ORM and SQLite",
"hautelook/alice-bundle": "Required when using loadFixtureFiles functionality with custom providers",
"theofidry/alice-data-fixtures": "Required when using loadFixtureFiles functionality"
},
"autoload": {
"psr-4": {
"Liip\\TestFixturesBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Liip\\Acme\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"ocramius/package-versions": true
}
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
{
"name": "Community contributions",
"homepage": "https://github.com/liip/LiipTestFixturesBundle/contributors"
}
],
"require": {
"php": "^7.4 || ^8.0",
"doctrine/common": "^2.13 || ^3.0",
"doctrine/persistence": "^1.3.3 || ^2.0 || ^3.0",
"symfony/deprecation-contracts": "^2.1 || ^3.0",
"symfony/event-dispatcher": "^5.4 || ^6.3 || ^7.0",
"symfony/event-dispatcher-contracts": "^1 || ^2 || ^3",
"symfony/framework-bundle": "^5.4 || ^6.3 || ^7.0",
"symfony/yaml": "^5.4 || ^6.3 || ^7.0"
},
"require-dev": {
"doctrine/annotations": "^1.13.1 || ^2.0",
"doctrine/data-fixtures": "^1.4.4",
"doctrine/dbal": "^2.13.1 || ^3.1",
"doctrine/doctrine-bundle": "^2.2",
"doctrine/doctrine-fixtures-bundle": "^3.4.4 || ^4.0",
"doctrine/mongodb-odm": "^2.2",
"doctrine/mongodb-odm-bundle": "^4.2.1 || ^5.0",
"doctrine/orm": "^2.14 || ^3.0",
"doctrine/phpcr-bundle": "^2.4.3 || ^3.0",
"doctrine/phpcr-odm": "^1.7.2 || ^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.10.1 || ^2.0",
"monolog/monolog": "^1.25.1 || ^2.0 || ^3.0",
"phpunit/phpunit": "^9.6.17 || ^10.5.11 || ^11.0.4",
"symfony/doctrine-bridge": "^5.4 || ^6.3 || ^7.0",
"symfony/monolog-bridge": "^5.4 || ^6.3 || ^7.0",
"symfony/monolog-bundle": "^3.2",
"symfony/phpunit-bridge": "^7.0",
"theofidry/alice-data-fixtures": "^1.5.2"
},
"conflict": {
"doctrine/annotations": "<1.13.1 || >=3.0",
"doctrine/dbal": "<2.13.1 || ~3.0.0 || >=4.0",
"doctrine/mongodb-odm": "<2.2 || >=3.0",
"doctrine/orm": "<2.14 || >=4.0"
},
"suggest": {
"doctrine/dbal": "Required when using the fixture loading functionality with an ORM and SQLite",
"doctrine/doctrine-fixtures-bundle": "Required when using the fixture loading functionality",
"doctrine/orm": "Required when using the fixture loading functionality with an ORM and SQLite",
"hautelook/alice-bundle": "Required when using loadFixtureFiles functionality with custom providers",
"theofidry/alice-data-fixtures": "Required when using loadFixtureFiles functionality"
},
"autoload": {
"psr-4": {
"Liip\\TestFixturesBundle\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Liip\\Acme\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true,
"allow-plugins": {
"composer/package-versions-deprecated": true,
"symfony/flex": true,
"ocramius/package-versions": true
}
},
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
}
}
}
3 changes: 3 additions & 0 deletions src/Services/DatabaseTools/ORMSqliteDatabaseTool.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public function loadFixtures(array $classNames = [], bool $append = false): Abst
$cacheDriver->clear();
}
} else {
# legacy
$cacheDriver = $config->getMetadataCacheImpl();

if ($cacheDriver) {
Expand Down Expand Up @@ -139,6 +140,7 @@ protected function disableForeignKeyChecksIfApplicable(): void
if (method_exists($this->connection, 'executeQuery')) {
$this->connection->executeQuery('PRAGMA foreign_keys = 0');
} else {
# legacy
$this->connection->query('PRAGMA foreign_keys = 0');
}

Expand All @@ -158,6 +160,7 @@ protected function enableForeignKeyChecksIfApplicable(): void
if (method_exists($this->connection, 'executeQuery')) {
$this->connection->executeQuery('PRAGMA foreign_keys = 1');
} else {
# legacy
$this->connection->query('PRAGMA foreign_keys = 1');
}

Expand Down
2 changes: 1 addition & 1 deletion tests/App/Entity/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class User
public function __construct()
{
$this->salt = sha1(
// http://php.net/manual/fr/function.openssl-random-pseudo-bytes.php
// http://php.net/manual/fr/function.openssl-random-pseudo-bytes.php
bin2hex(openssl_random_pseudo_bytes(100))
);
}
Expand Down
64 changes: 32 additions & 32 deletions tests/App/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@

# Tests/App/config.yml
framework:
secret: secret
test: ~
profiler:
collect: false
property_access: ~
secret: secret
test: ~
profiler:
collect: false
property_access: ~

monolog:
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug
handlers:
main:
type: fingers_crossed
action_level: error
handler: nested
nested:
type: stream
path: "%kernel.logs_dir%/%kernel.environment%.log"
level: debug

liip_test_fixtures: ~

doctrine:
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
LiipAcme:
dir: "%kernel.project_dir%/Entity"
prefix: 'Liip\Acme\Tests\App\Entity'
is_bundle: false
orm:
default_entity_manager: default
entity_managers:
default:
connection: default
mappings:
LiipAcme:
dir: "%kernel.project_dir%/Entity"
prefix: 'Liip\Acme\Tests\App\Entity'
is_bundle: false

services:
_defaults:
autowire: true
autoconfigure: true
_defaults:
autowire: true
autoconfigure: true

Liip\Acme\Tests\App\DataFixtures\ORM\:
resource: 'DataFixtures/ORM/*'
tags: ['doctrine.fixture.orm']
Liip\Acme\Tests\App\DataFixtures\ORM\:
resource: 'DataFixtures/ORM/*'
tags: ['doctrine.fixture.orm']

Liip\Acme\Tests\App\Service\:
resource: './Service/'
Liip\Acme\Tests\App\Service\:
resource: './Service/'
Loading