From a4e1ac2cd890fb0cfc6db40e27b63cb36fd24bf3 Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Mon, 10 Jun 2024 19:50:44 +0200 Subject: [PATCH 1/3] chore: removed deprecations in tests --- composer.json | 2 +- .../araiseSearchExtension.php | 2 +- tests/App/Factory/CompanyFactory.php | 22 +++++++++---------- tests/App/Factory/ComputerFactory.php | 14 ++++++------ tests/App/Factory/ContactFactory.php | 22 +++++++++---------- tests/App/Factory/DiskFactory.php | 14 ++++++------ tests/App/Factory/PersonFactory.php | 22 +++++++++---------- tests/App/config/packages/doctrine.yaml | 4 +++- .../config/packages/zenstruck_foundry.yaml | 1 - tests/ExceptionOnRemoveTest.php | 2 +- tests/IndexListenerTest.php | 6 ++--- 11 files changed, 56 insertions(+), 55 deletions(-) diff --git a/composer.json b/composer.json index 4823a84..1f25ff8 100644 --- a/composer.json +++ b/composer.json @@ -28,7 +28,7 @@ "symfony/validator": "^5.4|^6.4|^7.0", "doctrine/doctrine-bundle": "^2.5.5", "whatwedo/php-coding-standard": "^1.0", - "zenstruck/foundry": "^1.16", + "zenstruck/foundry": "^2.0", "zenstruck/console-test": "^v1.1.0", "symfony/translation": "^5.4|^6.4|^7.0", "symfony/twig-bundle": "^5.4|^6.4|^7.0", diff --git a/src/DependencyInjection/araiseSearchExtension.php b/src/DependencyInjection/araiseSearchExtension.php index f7fef02..752ff81 100644 --- a/src/DependencyInjection/araiseSearchExtension.php +++ b/src/DependencyInjection/araiseSearchExtension.php @@ -7,9 +7,9 @@ use araise\SearchBundle\Manager\IndexManager; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Extension\Extension; use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface; use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; -use Symfony\Component\HttpKernel\DependencyInjection\Extension; /** * This is the class that loads and manages your bundle configuration. diff --git a/tests/App/Factory/CompanyFactory.php b/tests/App/Factory/CompanyFactory.php index fc282eb..d4eab2c 100644 --- a/tests/App/Factory/CompanyFactory.php +++ b/tests/App/Factory/CompanyFactory.php @@ -6,9 +6,9 @@ use araise\SearchBundle\Tests\App\Entity\Company; use araise\SearchBundle\Tests\App\Repository\CompanyRepository; -use Zenstruck\Foundry\ModelFactory; -use Zenstruck\Foundry\Proxy; -use Zenstruck\Foundry\RepositoryProxy; +use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\Proxy; +use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; /** * @method static Company|Proxy createOne(array $attributes = []) @@ -23,12 +23,17 @@ * @method static Company[]|Proxy[] findBy(array $attributes) * @method static Company[]|Proxy[] randomSet(int $number, array $attributes = []) * @method static Company[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) - * @method static CompanyRepository|RepositoryProxy repository() + * @method static CompanyRepository|ProxyRepositoryDecorator repository() * @method Company|Proxy create($attributes = []) */ -final class CompanyFactory extends ModelFactory +final class CompanyFactory extends PersistentProxyObjectFactory { - protected function getDefaults(): array + public static function class(): string + { + return Company::class; + } + + protected function defaults(): array { return [ 'name' => self::faker()->company(), @@ -37,9 +42,4 @@ protected function getDefaults(): array 'taxIdentificationNumber' => self::faker()->numerify(self::faker()->countryCode().'###.####.###.#.###.##'), ]; } - - protected static function getClass(): string - { - return Company::class; - } } diff --git a/tests/App/Factory/ComputerFactory.php b/tests/App/Factory/ComputerFactory.php index 2402573..bf73383 100644 --- a/tests/App/Factory/ComputerFactory.php +++ b/tests/App/Factory/ComputerFactory.php @@ -30,9 +30,9 @@ namespace araise\SearchBundle\Tests\App\Factory; use araise\SearchBundle\Tests\App\Entity\Computer; -use Zenstruck\Foundry\ModelFactory; -use Zenstruck\Foundry\Proxy; -use Zenstruck\Foundry\RepositoryProxy; +use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\Proxy; +use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; /** * @method static Computer|Proxy createOne(array $attributes = []) @@ -47,17 +47,17 @@ * @method static Computer[]|Proxy[] findBy(array $attributes) * @method static Computer[]|Proxy[] randomSet(int $number, array $attributes = []) * @method static Computer[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) - * @method static RepositoryProxy repository() + * @method static ProxyRepositoryDecorator repository() * @method Computer|Proxy create($attributes = []) */ -class ComputerFactory extends ModelFactory +class ComputerFactory extends PersistentProxyObjectFactory { - protected static function getClass(): string + public static function class(): string { return Computer::class; } - protected function getDefaults(): array + protected function defaults(): array { return [ 'name' => self::faker()->colorName().'-'.self::faker()->randomNumber(3), diff --git a/tests/App/Factory/ContactFactory.php b/tests/App/Factory/ContactFactory.php index 1097f8c..90cb03a 100644 --- a/tests/App/Factory/ContactFactory.php +++ b/tests/App/Factory/ContactFactory.php @@ -6,9 +6,9 @@ use araise\SearchBundle\Tests\App\Entity\Contact; use araise\SearchBundle\Tests\App\Repository\ContactRepository; -use Zenstruck\Foundry\ModelFactory; -use Zenstruck\Foundry\Proxy; -use Zenstruck\Foundry\RepositoryProxy; +use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\Proxy; +use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; /** * @method static Contact|Proxy createOne(array $attributes = []) @@ -23,21 +23,21 @@ * @method static Contact[]|Proxy[] findBy(array $attributes) * @method static Contact[]|Proxy[] randomSet(int $number, array $attributes = []) * @method static Contact[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) - * @method static ContactRepository|RepositoryProxy repository() + * @method static ContactRepository|ProxyRepositoryDecorator repository() * @method Contact|Proxy create($attributes = []) */ -final class ContactFactory extends ModelFactory +final class ContactFactory extends PersistentProxyObjectFactory { - protected function getDefaults(): array + public static function class(): string + { + return Contact::class; + } + + protected function defaults(): array { return [ 'name' => self::faker()->name(), 'company' => CompanyFactory::randomOrCreate(), ]; } - - protected static function getClass(): string - { - return Contact::class; - } } diff --git a/tests/App/Factory/DiskFactory.php b/tests/App/Factory/DiskFactory.php index 0cd0005..a81b8c7 100644 --- a/tests/App/Factory/DiskFactory.php +++ b/tests/App/Factory/DiskFactory.php @@ -31,9 +31,9 @@ use araise\SearchBundle\Tests\App\Entity\Computer; use araise\SearchBundle\Tests\App\Entity\Disk; -use Zenstruck\Foundry\ModelFactory; -use Zenstruck\Foundry\Proxy; -use Zenstruck\Foundry\RepositoryProxy; +use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\Proxy; +use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; /** * @method static Computer|Proxy createOne(array $attributes = []) @@ -48,17 +48,17 @@ * @method static Computer[]|Proxy[] findBy(array $attributes) * @method static Computer[]|Proxy[] randomSet(int $number, array $attributes = []) * @method static Computer[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) - * @method static RepositoryProxy repository() + * @method static ProxyRepositoryDecorator repository() * @method Computer|Proxy create($attributes = []) */ -class DiskFactory extends ModelFactory +class DiskFactory extends PersistentProxyObjectFactory { - protected static function getClass(): string + public static function class(): string { return Disk::class; } - protected function getDefaults(): array + protected function defaults(): array { $number = self::faker()->numberBetween(1024, 1024 * 1024); return [ diff --git a/tests/App/Factory/PersonFactory.php b/tests/App/Factory/PersonFactory.php index 5562851..9ff4f33 100644 --- a/tests/App/Factory/PersonFactory.php +++ b/tests/App/Factory/PersonFactory.php @@ -6,9 +6,9 @@ use araise\SearchBundle\Tests\App\Entity\Person; use araise\SearchBundle\Tests\App\Repository\PersonRepository; -use Zenstruck\Foundry\ModelFactory; -use Zenstruck\Foundry\Proxy; -use Zenstruck\Foundry\RepositoryProxy; +use Zenstruck\Foundry\Persistence\PersistentProxyObjectFactory; +use Zenstruck\Foundry\Persistence\Proxy; +use Zenstruck\Foundry\Persistence\ProxyRepositoryDecorator; /** * @method static Person|Proxy createOne(array $attributes = []) @@ -23,20 +23,20 @@ * @method static Person[]|Proxy[] findBy(array $attributes) * @method static Person[]|Proxy[] randomSet(int $number, array $attributes = []) * @method static Person[]|Proxy[] randomRange(int $min, int $max, array $attributes = []) - * @method static PersonRepository|RepositoryProxy repository() + * @method static PersonRepository|ProxyRepositoryDecorator repository() * @method Person|Proxy create($attributes = []) */ -final class PersonFactory extends ModelFactory +final class PersonFactory extends PersistentProxyObjectFactory { - protected function getDefaults(): array + public static function class(): string { - return [ - 'name' => self::faker()->name(), - ]; + return Person::class; } - protected static function getClass(): string + protected function defaults(): array { - return Person::class; + return [ + 'name' => self::faker()->name(), + ]; } } diff --git a/tests/App/config/packages/doctrine.yaml b/tests/App/config/packages/doctrine.yaml index 614587c..801dda6 100644 --- a/tests/App/config/packages/doctrine.yaml +++ b/tests/App/config/packages/doctrine.yaml @@ -8,9 +8,11 @@ doctrine: charset: utf8mb4 default_table_options: charset: utf8mb4 - collate: utf8mb4_unicode_ci + collation: utf8mb4_unicode_ci url: '%env(resolve:DATABASE_URL)%' orm: + controller_resolver: + auto_mapping: true default_entity_manager: default auto_generate_proxy_classes: true entity_managers: diff --git a/tests/App/config/packages/zenstruck_foundry.yaml b/tests/App/config/packages/zenstruck_foundry.yaml index 58f0623..8c5b909 100644 --- a/tests/App/config/packages/zenstruck_foundry.yaml +++ b/tests/App/config/packages/zenstruck_foundry.yaml @@ -1,2 +1 @@ zenstruck_foundry: - auto_refresh_proxies: true \ No newline at end of file diff --git a/tests/ExceptionOnRemoveTest.php b/tests/ExceptionOnRemoveTest.php index 15a98ca..e226d4f 100644 --- a/tests/ExceptionOnRemoveTest.php +++ b/tests/ExceptionOnRemoveTest.php @@ -75,7 +75,7 @@ public function testDoesNotRemoveFromIndexWhenExceptionWhileDeleting(): void protected function setUp(): void { - $this->disk = DiskFactory::createOne()->object(); + $this->disk = DiskFactory::createOne()->_real(); self::assertNotNull($this->disk->getId()); self::assertNotNull($this->disk->getComputer()->getId()); $this->computerName = $this->disk->getComputer()->getName(); diff --git a/tests/IndexListenerTest.php b/tests/IndexListenerTest.php index de4603d..5405d1a 100644 --- a/tests/IndexListenerTest.php +++ b/tests/IndexListenerTest.php @@ -27,7 +27,7 @@ public function testEntityCreation(): void 'country' => 'Switzerland', 'taxIdentificationNumber' => '12344566', ]), - ])->object(); + ])->_real(); $indexResults = $em->getRepository(Index::class)->findAll(); self::assertCount(6, $indexResults); @@ -65,7 +65,7 @@ public function testEntityUpdate(): void 'country' => 'Switzerland', 'taxIdentificationNumber' => '12344566', ]), - ])->object(); + ])->_real(); $contactId = $contact->getId(); @@ -115,7 +115,7 @@ public function testEntityDelete(): void 'country' => 'country', 'taxIdentificationNumber' => '123456', ]), - ])->object(); + ])->_real(); $contactId = $contact->getId(); From c950e6d6fa14567ae6041c15508bac1beed8d2ba Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Tue, 11 Jun 2024 16:19:17 +0200 Subject: [PATCH 2/3] feature(test): added strategy matrix for php and symfony --- .github/workflows/ci.yaml | 43 +++++++++++++++++++++++++++++---------- composer.json | 18 ++++++++-------- 2 files changed, 41 insertions(+), 20 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 717ffd5..6c62b44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: searchBundle +name: PHP Symfony CI on: push: @@ -10,25 +10,46 @@ env: DATABASE_URL: mysql://root:root@127.0.0.1/search_bundle jobs: - phpunit: + build: runs-on: ubuntu-latest + + strategy: + matrix: + php: [8.1, 8.2, 8.3] + symfony: [6.4.*, 7.0.*, 7.1.*] + exclude: + - php: 8.1 + symfony: 7.1.* + - php: 8.1 + symfony: 7.0.* + services: mysql: - image: mysql:5.7 + image: mysql:latest env: MYSQL_ROOT_PASSWORD: root ports: - 3306:3306 + options: >- + --health-cmd "mysqladmin ping --silent" + --health-interval 10s + --health-timeout 5s + --health-retries 3 + steps: - - uses: shivammathur/setup-php@2cb9b829437ee246e9b3cac53555a39208ca6d28 + - uses: actions/checkout@v4 + - name: Setup PHP ${{ matrix.php }} + uses: shivammathur/setup-php@v2 with: - php-version: '8.1' - - uses: actions/checkout@v2 - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist - - name: Execute tests (Unit and Feature tests) via PHPUnit + php-version: ${{ matrix.php }} + tools: flex + - name: Download dependencies + env: + SYMFONY_REQUIRE: ${{ matrix.symfony }} + uses: ramsey/composer-install@v2 + - name: Run test suite on PHP ${{ matrix.php }} and Symfony ${{ matrix.symfony }} run: vendor/bin/simple-phpunit - - name: Check Code Styles + - name: Run ECS run: vendor/bin/ecs - - name: Check PHP Stan + - name: Run PHPStan run: vendor/bin/phpstan analyse src tests diff --git a/composer.json b/composer.json index 1f25ff8..6a03617 100644 --- a/composer.json +++ b/composer.json @@ -13,25 +13,25 @@ ], "require": { "php": ">=8.1", - "symfony/framework-bundle": "^5.4|^6.4|^7.0", - "symfony/http-kernel": "^5.4|^6.4|^7.0", + "symfony/framework-bundle": "^6.4|^7.0", + "symfony/http-kernel": "^6.4|^7.0", "doctrine/annotations": "^1.13.2|^2.0", "doctrine/orm": "^2.13.3|^3.1", "araise/core-bundle": "^1.1", "doctrine/doctrine-migrations-bundle": "^3.2" }, "require-dev": { - "symfony/phpunit-bridge": "^5.4|^6.4|^7.0", - "symfony/config": "^5.4|^6.4|^7.0", - "symfony/dependency-injection": "^5.4|^6.4|^7.0", - "symfony/yaml": "^5.4|^6.4|^7.0", - "symfony/validator": "^5.4|^6.4|^7.0", + "symfony/phpunit-bridge": "^6.4|^7.0", + "symfony/config": "^6.4|^7.0", + "symfony/dependency-injection": "^6.4|^7.0", + "symfony/yaml": "^6.4|^7.0", + "symfony/validator": "^6.4|^7.0", "doctrine/doctrine-bundle": "^2.5.5", "whatwedo/php-coding-standard": "^1.0", "zenstruck/foundry": "^2.0", "zenstruck/console-test": "^v1.1.0", - "symfony/translation": "^5.4|^6.4|^7.0", - "symfony/twig-bundle": "^5.4|^6.4|^7.0", + "symfony/translation": "^6.4|^7.0", + "symfony/twig-bundle": "^6.4|^7.0", "phpstan/phpstan": "^1.7" }, "autoload": { From 113569db451853f010a1c89f7c1a0ebbd515f049 Mon Sep 17 00:00:00 2001 From: tuxes3 Date: Tue, 8 Oct 2024 13:18:52 +0200 Subject: [PATCH 3/3] chore: added Changelog for v3.2.0 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 32d96b1..2bd25e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # CHANGELOG +## v3.2.0 + - Removed symfony ^5.4 support + ## v3.0.5 - More documentation and better styling of the documentation