Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into TeDo-Verlag/master
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry committed Nov 13, 2024
2 parents 524c2ce + 821a4bb commit 7ac7620
Show file tree
Hide file tree
Showing 18 changed files with 91 additions and 78 deletions.
31 changes: 15 additions & 16 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
fail-fast: false
matrix:
php-version:
- '8.2'
- '8.3'
dependencies: [ highest, lowest ]
make-test:
- test_core
Expand All @@ -38,8 +38,7 @@ jobs:
- test_symfony_eloquent_bridge_proxy_manager
variant:
- 'no-change'
- '"symfony/symfony:^5.4"'
- '"symfony/symfony:^6.4"'
- '"symfony/symfony:^6.4.14"'
# To keep in sync with docker-compose.yml
services:
mysql:
Expand Down Expand Up @@ -97,84 +96,82 @@ jobs:
# in the wiki merge plugin
- name: Install doctrine Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine
- name: Repeat "Install doctrine Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine

- name: Install MongoDB Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_odm_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine_mongodb
- name: Repeat "Install MongoDB Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_odm_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine_mongodb

- name: Install Doctrine PHPCR Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_phpcr_bridge' || matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine_phpcr
- name: Repeat "Install Doctrine PHPCR Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_doctrine_phpcr_bridge' || matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/doctrine_phpcr

- name: Install Eloquent Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_eloquent_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/eloquent
- name: Repeat "Install Eloquent Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_eloquent_bridge'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/eloquent

# There is a known issue here with Composer
# see https://github.com/composer/composer/issues/10200
# Meanwhile we break down the installation as a workaround.
# Once this is fixed the whole bin dependencies can probably be installed
# in one step with a timeout adjustment
- name: Remove Symfony from ProxyManager Composer bin dependencies
if: matrix.variant != 'no-change'
run: composer bin proxy-manager remove --dev --no-update symfony/symfony

- name: Install ProxyManager Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/proxy-manager
- name: Repeat "Install ProxyManager Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/proxy-manager

- name: Add back Symfony (variant) for ProxyManager Composer bin dependencies
if: matrix.variant != 'no-change'
run: composer bin proxy-manager require --dev --no-update ${{ matrix.variant }}

- name: Install Symfony for ProxyManager Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
Expand All @@ -186,12 +183,14 @@ jobs:

- name: Install Symfony Composer bin dependencies
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager' || matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
working-directory: vendor-bin/symfony
- name: Repeat "Install Symfony Composer bin dependencies"
uses: ramsey/composer-install@v3
if: "matrix.make-test == 'test_symfony_bridge' || matrix.make-test == 'test_symfony_doctrine_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge' || matrix.make-test == 'test_symfony_eloquent_bridge_proxy_manager' || matrix.make-test == 'test_symfony_doctrine_bridge_proxy_manager'"
with:
dependency-versions: "${{ matrix.dependencies }}"
composer-options: "${{ matrix.composer-flags }}"
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
PHP_CS_FIXER=php -d zend.enable_gc=0 vendor-bin/php-cs-fixer/bin/php-cs-fixer
DOCKER_COMPOSE=docker-compose
DOCKER_COMPOSE=docker compose
DOCKER_COMPOSE_EXEC=$(DOCKER_COMPOSE) exec --no-TTY
ifeq ("$(CI)", "true")
MYSQL_BIN=mysql --user=root --password=password --port=3307
MONGO_BIN=mongosh --username=root --password=password --port=27018
else
MYSQL_BIN=$(DOCKER_COMPOSE_EXEC) mysql mysql --user=root --password=password --port=3307
MONGO_BIN=$(DOCKER_COMPOSE_EXEC) mongo mongosh --username=root --password=password --port=27017
MYSQL_BIN=$(DOCKER_COMPOSE_EXEC) mysql mysql --user=root --password=password --host=host.docker.internal --port=3307
MONGO_BIN=$(DOCKER_COMPOSE_EXEC) mongo mongosh --username=root --password=password --host=host.docker.internal --port=27018
endif

.DEFAULT_GOAL := help
Expand Down Expand Up @@ -114,7 +114,7 @@ test_doctrine_odm_bridge: vendor/bamarni \
.PHONY: test_doctrine_phpcr_bridge
test_doctrine_phpcr_bridge: ## Run the tests for the Doctrine Mongodb PHPCR bridge
test_doctrine_phpcr_bridge: vendor/bamarni \
vendor-bin/doctrine_mongodb/vendor/phpunit
vendor-bin/doctrine_phpcr/vendor/phpunit
$(MAKE) remove_sf_cache
$(MAKE) refresh_phpcr

Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ AliceDataFixtures

Supports:

* Symfony 5.4+, 6.4+
* Doctrine ORM 2.5+
* Symfony 6.4+
* Doctrine ORM 2.20+
* Doctrine ODM 2.0+
* Doctrine PHPCR 1.4+
* Eloquent 8.12+
* Doctrine PHPCR 2.0+
* Eloquent 11.0+


## Documentation
Expand Down
14 changes: 10 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"php": "^8.2",
"php": "^8.3",
"nelmio/alice": "^3.10",
"psr/log": "^1 || ^2 || ^3",
"webmozart/assert": "^1.10"
Expand All @@ -33,12 +33,18 @@
"symfony/phpunit-bridge": "^5.3.8 || ^6.4"
},
"conflict": {
"doctrine/orm": "<2.6.3",
"doctrine/data-fixtures": "<1.7.0",
"doctrine/orm": "<2.20",
"doctrine/doctrine-bundle": "<2.11.0",
"doctrine/mongodb-odm-bundle": "<5.1.0",
"doctrine/mongodb-odm": "<2.6.0",
"doctrine/phpcr-bundle": "<3.0",
"doctrine/phpcr-odm": "<2.0.0",
"doctrine/dbal": "<3.0",
"doctrine/persistence": "<2.0",
"illuminate/database": "<8.12",
"illuminate/database": "<10.0",
"ocramius/proxy-manager": "<2.1",
"symfony/framework-bundle": "<5.4 || >=6.0 <6.4",
"symfony/framework-bundle": ">=6.0 <6.4",
"zendframework/zend-code": "<3.3.1"
},
"suggest": {
Expand Down
2 changes: 0 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: '3.1'

# To keep in sync with .gitHub/workflows/tests.yaml
services:
mysql:
Expand Down
1 change: 1 addition & 0 deletions doctrine-phpcr-db-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@
'dbname' => get_param('DOCTRINE_PHPCR_DB_NAME', 'fidry_alice_data_fixtures'),
'host' => get_param('DOCTRINE_PHPCR_DB_HOST', '127.0.0.1'),
'port' => get_param('DOCTRINE_PHPCR_DB_PORT', 3307),
'charset' => get_param('DOCTRINE_PHPCR_DB_CHARSET', 'UTF8'),
];
12 changes: 4 additions & 8 deletions fixtures/Bridge/Doctrine/PhpCrDocument/Dummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@

namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument;

use Doctrine\ODM\PHPCR\Mapping\Annotations\Document;
use Doctrine\ODM\PHPCR\Mapping\Annotations\Id;
use Doctrine\ODM\PHPCR\Mapping\Attributes\Document;
use Doctrine\ODM\PHPCR\Mapping\Attributes\Id;

/**
* @Document()
*/
#[Document]
class Dummy
{
/**
* @Id()
*/
#[Id]
public $id;
}
6 changes: 2 additions & 4 deletions fixtures/Bridge/Doctrine/PhpCrDocument/DummySubClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@

namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument;

use Doctrine\ODM\PHPCR\Mapping\Annotations\Document;
use Doctrine\ODM\PHPCR\Mapping\Attributes\Document;

/**
* @Document()
*/
#[Document]
class DummySubClass extends MappedSuperclassDummy
{
}
18 changes: 6 additions & 12 deletions fixtures/Bridge/Doctrine/PhpCrDocument/MappedSuperclassDummy.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,16 @@

namespace Fidry\AliceDataFixtures\Bridge\Doctrine\PhpCrDocument;

use Doctrine\ODM\PHPCR\Mapping\Annotations\Field;
use Doctrine\ODM\PHPCR\Mapping\Annotations\Id;
use Doctrine\ODM\PHPCR\Mapping\Annotations\MappedSuperclass;
use Doctrine\ODM\PHPCR\Mapping\Attributes\Field;
use Doctrine\ODM\PHPCR\Mapping\Attributes\Id;
use Doctrine\ODM\PHPCR\Mapping\Attributes\MappedSuperclass;

/**
* @MappedSuperclass()
*/
#[MappedSuperclass]
class MappedSuperclassDummy
{
/**
* @Id()
*/
#[Id]
public $id;

/**
* @Field(type="string")
*/
#[Field(type: 'string')]
public string $status;
}
5 changes: 5 additions & 0 deletions fixtures/Bridge/Symfony/SymfonyApp/config/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
#

framework:
http_method_override: false
handle_all_throwables: false
php_errors:
log: true
secret: test
router:
resource: ~
Expand All @@ -16,6 +20,7 @@ framework:
enabled: false
validation:
enabled: true
email_validation_mode: html5
session:
enabled: false
test: ~
Expand Down
3 changes: 3 additions & 0 deletions fixtures/Bridge/Symfony/SymfonyApp/config/config_doctrine.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ doctrine:
1002: "SET NAMES 'UTF8' COLLATE 'utf8_unicode_ci'"
orm:
auto_mapping: true
controller_resolver:
auto_mapping: false
enable_lazy_ghost_objects: true
mappings:
fixture_entities:
type: xml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@
#

framework:
http_method_override: false
handle_all_throwables: false
php_errors:
log: true
secret: test
router:
resource: ~
form:
enabled: false
validation:
enabled: true
email_validation_mode: html5
session: ~
test: ~
30 changes: 24 additions & 6 deletions tests/Bridge/Doctrine/Purger/PurgerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
namespace Fidry\AliceDataFixtures\Bridge\Doctrine\Purger;

use Doctrine\Common\DataFixtures\Purger\ORMPurger as DoctrineOrmPurger;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\ClassMetadataFactory;
use Doctrine\Persistence\Mapping\Driver\MappingDriver;
use Fidry\AliceDataFixtures\Bridge\Doctrine\ORM\FakeEntityManager;
use Fidry\AliceDataFixtures\Persistence\PurgeMode;
use Fidry\AliceDataFixtures\Persistence\PurgerFactoryInterface;
Expand Down Expand Up @@ -66,24 +70,38 @@ public function testCreatesADoctrineOrmPurgerWithTheAppropriateManagerAndPurgeMo

public function testDisableFKChecksOnDeleteIsPerformed(): void
{
$mappingDriverProphecy = $this->prophesize(MappingDriver::class);
$mappingDriverProphecy->getAllClassNames()->willReturn([]);

$configuration = new Configuration();
$configuration->setMetadataDriverImpl($mappingDriverProphecy->reveal());

$connection = $this->prophesize(Connection::class);
$connection->getConfiguration()->willReturn($configuration);
$connection->getDatabasePlatform()->willReturn($this->prophesize(MySqlPlatform::class)->reveal());
$connection->exec('SET FOREIGN_KEY_CHECKS = 0;')->shouldBeCalled();
$connection->exec('SET FOREIGN_KEY_CHECKS = 1;')->shouldBeCalled();
$connection->executeStatement('SET FOREIGN_KEY_CHECKS = 0;')->shouldBeCalled();
$connection->executeStatement('SET FOREIGN_KEY_CHECKS = 1;')->shouldBeCalled();

$classMetadataFactory = new ClassMetadataFactory();

$manager = $this->prophesize(EntityManager::class);
$manager->getConfiguration()->willReturn($configuration);
$manager->getConnection()->willReturn($connection->reveal());
$manager->getEventManager()->willReturn(new EventManager());
$manager->getMetadataFactory()->willReturn($classMetadataFactory);

$classMetadataFactory->setEntityManager($manager->reveal());

$purgerORM = $this->prophesize(DoctrineOrmPurger::class);
$purgerORM->getObjectManager()->willReturn($manager->reveal());
$purgerORM->purge()->shouldBeCalled();
$purgerORM = new DoctrineOrmPurger(
$manager->reveal(),
);

$purgeMode = PurgeMode::createDeleteMode();
$purger = new Purger($manager->reveal(), $purgeMode);

$decoratedPurgerReflection = (new ReflectionObject($purger))->getProperty('purger');
$decoratedPurgerReflection->setAccessible(true);
$decoratedPurgerReflection->setValue($purger, $purgerORM->reveal());
$decoratedPurgerReflection->setValue($purger, $purgerORM);

$purger->purge();
}
Expand Down
Loading

0 comments on commit 7ac7620

Please sign in to comment.