diff --git a/api-platform/api/.env.test b/api-platform/api/.env.test index e3d5d8bdb0b83e3842c90056147190b87841ca79..536965f258a30dbb248a354465ff1792163eb14f 100644 --- a/api-platform/api/.env.test +++ b/api-platform/api/.env.test @@ -7,3 +7,7 @@ PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots # API Platform distribution TRUSTED_HOSTS=^example\.com|localhost$ + +APP_ENV=test + +DATABASE_URL="postgresql://app:!ChangeMe!@database:5432/app_test?serverVersion=16&charset=utf8" diff --git a/api-platform/api/composer.json b/api-platform/api/composer.json index f68eb6cc80288ec4f6b9e9a4d694c58bf5498bd1..bd397837e4aeb7654ec87e11524d2165269f9c7a 100644 --- a/api-platform/api/composer.json +++ b/api-platform/api/composer.json @@ -32,6 +32,7 @@ }, "require-dev": { "api-platform/schema-generator": "^5.0", + "dama/doctrine-test-bundle": "^8.3", "doctrine/doctrine-fixtures-bundle": "^4.3", "phpoffice/phpspreadsheet": "^5.4", "symfony/browser-kit": "7.2.*", @@ -41,7 +42,8 @@ "symfony/phpunit-bridge": "7.2.*", "symfony/stopwatch": "7.2.*", "symfony/var-dumper": "7.2.*", - "symfony/web-profiler-bundle": "7.2.*" + "symfony/web-profiler-bundle": "7.2.*", + "zenstruck/foundry": "^2.9" }, "config": { "optimize-autoloader": true, diff --git a/api-platform/api/composer.lock b/api-platform/api/composer.lock index e5b2bdbbd0175bb49c39366f56aabbdae0077c0c..fd194209554c651d6bee1a0296785222fe9ffae6 100644 --- a/api-platform/api/composer.lock +++ b/api-platform/api/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "4aa52f0fd0cd346f50dc5d5b9c9e483f", + "content-hash": "2379e6b4d928d5171109f603a303b3f5", "packages": [ { "name": "api-platform/doctrine-common", @@ -7697,6 +7697,75 @@ ], "time": "2024-05-06T16:37:16+00:00" }, + { + "name": "dama/doctrine-test-bundle", + "version": "v8.3.1", + "source": { + "type": "git", + "url": "https://github.com/dmaicher/doctrine-test-bundle.git", + "reference": "9bc47e02a0d67cbfef6773837249f71e65c95bf6" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/dmaicher/doctrine-test-bundle/zipball/9bc47e02a0d67cbfef6773837249f71e65c95bf6", + "reference": "9bc47e02a0d67cbfef6773837249f71e65c95bf6", + "shasum": "" + }, + "require": { + "doctrine/dbal": "^3.3 || ^4.0", + "doctrine/doctrine-bundle": "^2.11.0", + "php": ">= 8.1", + "psr/cache": "^2.0 || ^3.0", + "symfony/cache": "^6.4 || ^7.2 || ^8.0", + "symfony/framework-bundle": "^6.4 || ^7.2 || ^8.0" + }, + "conflict": { + "phpunit/phpunit": "<10.0" + }, + "require-dev": { + "behat/behat": "^3.0", + "friendsofphp/php-cs-fixer": "^3.27", + "phpstan/phpstan": "^2.0", + "phpunit/phpunit": "^10.0 || ^11.0 || ^12.0", + "symfony/process": "^6.4 || ^7.2 || ^8.0", + "symfony/yaml": "^6.4 || ^7.2 || ^8.0" + }, + "type": "symfony-bundle", + "extra": { + "branch-alias": { + "dev-master": "8.x-dev" + } + }, + "autoload": { + "psr-4": { + "DAMA\\DoctrineTestBundle\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "David Maicher", + "email": "mail@dmaicher.de" + } + ], + "description": "Symfony bundle to isolate doctrine database tests and improve test performance", + "keywords": [ + "doctrine", + "isolation", + "performance", + "symfony", + "testing", + "tests" + ], + "support": { + "issues": "https://github.com/dmaicher/doctrine-test-bundle/issues", + "source": "https://github.com/dmaicher/doctrine-test-bundle/tree/v8.3.1" + }, + "time": "2025-08-05T17:55:02+00:00" + }, { "name": "devizzent/cebe-php-openapi", "version": "1.1.4", @@ -7989,6 +8058,69 @@ }, "time": "2023-08-08T05:53:35+00:00" }, + { + "name": "fakerphp/faker", + "version": "v1.24.1", + "source": { + "type": "git", + "url": "https://github.com/FakerPHP/Faker.git", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/FakerPHP/Faker/zipball/e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "reference": "e0ee18eb1e6dc3cda3ce9fd97e5a0689a88a64b5", + "shasum": "" + }, + "require": { + "php": "^7.4 || ^8.0", + "psr/container": "^1.0 || ^2.0", + "symfony/deprecation-contracts": "^2.2 || ^3.0" + }, + "conflict": { + "fzaninotto/faker": "*" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.4.1", + "doctrine/persistence": "^1.3 || ^2.0", + "ext-intl": "*", + "phpunit/phpunit": "^9.5.26", + "symfony/phpunit-bridge": "^5.4.16" + }, + "suggest": { + "doctrine/orm": "Required to use Faker\\ORM\\Doctrine", + "ext-curl": "Required by Faker\\Provider\\Image to download images.", + "ext-dom": "Required by Faker\\Provider\\HtmlLorem for generating random HTML.", + "ext-iconv": "Required by Faker\\Provider\\ru_RU\\Text::realText() for generating real Russian text.", + "ext-mbstring": "Required for multibyte Unicode string functionality." + }, + "type": "library", + "autoload": { + "psr-4": { + "Faker\\": "src/Faker/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "François Zaninotto" + } + ], + "description": "Faker is a PHP library that generates fake data for you.", + "keywords": [ + "data", + "faker", + "fixtures" + ], + "support": { + "issues": "https://github.com/FakerPHP/Faker/issues", + "source": "https://github.com/FakerPHP/Faker/tree/v1.24.1" + }, + "time": "2024-11-21T13:46:39+00:00" + }, { "name": "fidry/cpu-core-counter", "version": "1.2.0", @@ -10391,16 +10523,16 @@ }, { "name": "symfony/phpunit-bridge", - "version": "v7.2.0", + "version": "v7.2.8", "source": { "type": "git", "url": "https://github.com/symfony/phpunit-bridge.git", - "reference": "2bbde92ab25a0e2c88160857af7be9db5da0d145" + "reference": "860206b88792463da3bb64763c224c29ddbe9729" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/2bbde92ab25a0e2c88160857af7be9db5da0d145", - "reference": "2bbde92ab25a0e2c88160857af7be9db5da0d145", + "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/860206b88792463da3bb64763c224c29ddbe9729", + "reference": "860206b88792463da3bb64763c224c29ddbe9729", "shasum": "" }, "require": { @@ -10452,8 +10584,11 @@ ], "description": "Provides utilities for PHPUnit, especially user deprecation notices management", "homepage": "https://symfony.com", + "keywords": [ + "testing" + ], "support": { - "source": "https://github.com/symfony/phpunit-bridge/tree/v7.2.0" + "source": "https://github.com/symfony/phpunit-bridge/tree/v7.2.8" }, "funding": [ { @@ -10469,7 +10604,87 @@ "type": "tidelift" } ], - "time": "2024-11-13T16:15:23+00:00" + "time": "2025-06-04T10:08:59+00:00" + }, + { + "name": "symfony/polyfill-php85", + "version": "v1.33.0", + "source": { + "type": "git", + "url": "https://github.com/symfony/polyfill-php85.git", + "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/symfony/polyfill-php85/zipball/d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", + "reference": "d4e5fcd4ab3d998ab16c0db48e6cbb9a01993f91", + "shasum": "" + }, + "require": { + "php": ">=7.2" + }, + "type": "library", + "extra": { + "thanks": { + "url": "https://github.com/symfony/polyfill", + "name": "symfony/polyfill" + } + }, + "autoload": { + "files": [ + "bootstrap.php" + ], + "psr-4": { + "Symfony\\Polyfill\\Php85\\": "" + }, + "classmap": [ + "Resources/stubs" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Nicolas Grekas", + "email": "p@tchwork.com" + }, + { + "name": "Symfony Community", + "homepage": "https://symfony.com/contributors" + } + ], + "description": "Symfony polyfill backporting some PHP 8.5+ features to lower PHP versions", + "homepage": "https://symfony.com", + "keywords": [ + "compatibility", + "polyfill", + "portable", + "shim" + ], + "support": { + "source": "https://github.com/symfony/polyfill-php85/tree/v1.33.0" + }, + "funding": [ + { + "url": "https://symfony.com/sponsor", + "type": "custom" + }, + { + "url": "https://github.com/fabpot", + "type": "github" + }, + { + "url": "https://github.com/nicolas-grekas", + "type": "github" + }, + { + "url": "https://tidelift.com/funding/github/packagist/symfony/symfony", + "type": "tidelift" + } + ], + "time": "2025-06-23T16:12:55+00:00" }, { "name": "symfony/process", @@ -10614,6 +10829,193 @@ ], "time": "2025-02-14T14:27:24+00:00" }, + { + "name": "zenstruck/assert", + "version": "v1.7.0", + "source": { + "type": "git", + "url": "https://github.com/zenstruck/assert.git", + "reference": "1e32d48847d4e82c345112ca226b21a1a792af0a" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zenstruck/assert/zipball/1e32d48847d4e82c345112ca226b21a1a792af0a", + "reference": "1e32d48847d4e82c345112ca226b21a1a792af0a", + "shasum": "" + }, + "require": { + "php": ">=8.1", + "symfony/polyfill-php81": "^1.23", + "symfony/var-exporter": "^5.4|^6.0|^7.0|^8.0" + }, + "require-dev": { + "phpstan/phpstan": "^1.4", + "phpunit/phpunit": "^9.5.21", + "symfony/phpunit-bridge": "^6.3|^7.0|^8.0" + }, + "type": "library", + "autoload": { + "psr-4": { + "Zenstruck\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Bond", + "email": "kevinbond@gmail.com" + } + ], + "description": "Standalone, lightweight, framework agnostic, test assertion library.", + "homepage": "https://github.com/zenstruck/assert", + "keywords": [ + "assertion", + "phpunit", + "test" + ], + "support": { + "issues": "https://github.com/zenstruck/assert/issues", + "source": "https://github.com/zenstruck/assert/tree/v1.7.0" + }, + "funding": [ + { + "url": "https://github.com/kbond", + "type": "github" + }, + { + "url": "https://github.com/nikophil", + "type": "github" + } + ], + "time": "2025-12-07T01:59:12+00:00" + }, + { + "name": "zenstruck/foundry", + "version": "v2.9.1", + "source": { + "type": "git", + "url": "https://github.com/zenstruck/foundry.git", + "reference": "304e5333e62745a8f1b70e40b284c1d278b61cf0" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/zenstruck/foundry/zipball/304e5333e62745a8f1b70e40b284c1d278b61cf0", + "reference": "304e5333e62745a8f1b70e40b284c1d278b61cf0", + "shasum": "" + }, + "require": { + "fakerphp/faker": "^1.24", + "php": ">=8.1", + "symfony/deprecation-contracts": "^2.2|^3.0", + "symfony/polyfill-php84": "^1.32", + "symfony/polyfill-php85": "^1.33", + "symfony/property-access": "^6.4|^7.0|^8.0", + "symfony/property-info": "^6.4|^7.0|^8.0", + "symfony/var-exporter": "^6.4.9|~7.0.9|^7.1.2|^8.0", + "zenstruck/assert": "^1.4" + }, + "conflict": { + "doctrine/cache": "<1.12.1", + "doctrine/persistence": "<2.0" + }, + "require-dev": { + "bamarni/composer-bin-plugin": "^1.8", + "dama/doctrine-test-bundle": "^8.0", + "doctrine/collections": "^1.7|^2.0", + "doctrine/common": "^3.2.2", + "doctrine/doctrine-bundle": "^2.10|^3.0", + "doctrine/doctrine-migrations-bundle": "^2.2|^3.0", + "doctrine/mongodb-odm": "^2.4", + "doctrine/mongodb-odm-bundle": "^4.6|^5.0", + "doctrine/orm": "^2.16|^3.0", + "doctrine/persistence": "^2.0|^3.0|^4.0", + "phpunit/phpunit": "^9.5.0 || ^10.0 || ^11.0 || ^12.0 || ^13.0", + "symfony/browser-kit": "^6.4|^7.0|^8.0", + "symfony/console": "^6.4|^7.0|^8.0", + "symfony/dotenv": "^6.4|^7.0|^8.0", + "symfony/event-dispatcher": "^6.4|^7.0|^8.0", + "symfony/flex": "^2.10", + "symfony/framework-bundle": "^6.4|^7.0|^8.0", + "symfony/maker-bundle": "^1.55", + "symfony/phpunit-bridge": "^6.4.26|^7.0|^8.0", + "symfony/routing": "^6.4|^7.0|^8.0", + "symfony/runtime": "^6.4|^7.0|^8.0", + "symfony/translation-contracts": "^3.4", + "symfony/uid": "^6.4|^7.0|^8.0", + "symfony/var-dumper": "^6.4|^7.0|^8.0", + "symfony/yaml": "^6.4|^7.0|^8.0", + "webmozart/assert": "^1.11" + }, + "type": "library", + "extra": { + "psalm": { + "pluginClass": "Zenstruck\\Foundry\\Psalm\\FoundryPlugin" + }, + "symfony": { + "allow-contrib": false + }, + "bamarni-bin": { + "bin-links": true, + "forward-command": false, + "target-directory": "bin/tools" + } + }, + "autoload": { + "files": [ + "src/functions.php", + "src/Persistence/functions.php", + "src/symfony_console.php" + ], + "psr-4": { + "Zenstruck\\Foundry\\": "src/", + "Zenstruck\\Foundry\\Psalm\\": "utils/psalm", + "Zenstruck\\Foundry\\Utils\\Rector\\": "utils/rector/src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Kevin Bond", + "email": "kevinbond@gmail.com" + }, + { + "name": "Nicolas PHILIPPE", + "email": "nikophil@gmail.com" + } + ], + "description": "A model factory library for creating expressive, auto-completable, on-demand dev/test fixtures with Symfony and Doctrine.", + "homepage": "https://github.com/zenstruck/foundry", + "keywords": [ + "Fixture", + "dev", + "doctrine", + "factory", + "faker", + "symfony", + "test" + ], + "support": { + "issues": "https://github.com/zenstruck/foundry/issues", + "source": "https://github.com/zenstruck/foundry/tree/v2.9.1" + }, + "funding": [ + { + "url": "https://github.com/kbond", + "type": "github" + }, + { + "url": "https://github.com/nikophil", + "type": "github" + } + ], + "time": "2026-02-08T14:53:41+00:00" + }, { "name": "zozlak/rdf-constants", "version": "1.2.1", diff --git a/api-platform/api/config/bundles.php b/api-platform/api/config/bundles.php index 7c3f10225929a4c11c2d0b461a63f510b79edbf7..7cf6071aadd68d26cf8884c7759aed823db138c4 100644 --- a/api-platform/api/config/bundles.php +++ b/api-platform/api/config/bundles.php @@ -14,4 +14,5 @@ return [ Symfony\Bundle\MonologBundle\MonologBundle::class => ['all' => true], Symfony\Bundle\DebugBundle\DebugBundle::class => ['dev' => true, 'test' => true], Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['dev' => true, 'test' => true], + Zenstruck\Foundry\ZenstruckFoundryBundle::class => ['dev' => true, 'test' => true], ]; diff --git a/api-platform/api/config/packages/zenstruck_foundry.yaml b/api-platform/api/config/packages/zenstruck_foundry.yaml new file mode 100644 index 0000000000000000000000000000000000000000..e3ed04b46956154e87305b5a5ad68da53f47f356 --- /dev/null +++ b/api-platform/api/config/packages/zenstruck_foundry.yaml @@ -0,0 +1,5 @@ +when@dev: &dev + # See full configuration: https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#full-default-bundle-configuration + zenstruck_foundry: + +when@test: *dev diff --git a/api-platform/api/src/Factory/CommuneFactory.php b/api-platform/api/src/Factory/CommuneFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..3ecfc3ccf18b5a490df9f32c834f70a549449496 --- /dev/null +++ b/api-platform/api/src/Factory/CommuneFactory.php @@ -0,0 +1,43 @@ + + */ +final class CommuneFactory extends PersistentObjectFactory +{ + #[\Override] + public static function class(): string + { + return Commune::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + */ + #[\Override] + protected function defaults(): array|callable + { + return [ + 'code' => self::faker()->randomNumber(), + 'departement' => DepartementFactory::new(), + 'nom' => self::faker()->text(255), + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + #[\Override] + protected function initialize(): static + { + return $this + // ->afterInstantiate(function(Commune $commune): void {}) + ; + } +} diff --git a/api-platform/api/src/Factory/DepartementFactory.php b/api-platform/api/src/Factory/DepartementFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..8ae777d166a8876c61caa1da6a4a67acf2ad1a5f --- /dev/null +++ b/api-platform/api/src/Factory/DepartementFactory.php @@ -0,0 +1,43 @@ + + */ +final class DepartementFactory extends PersistentObjectFactory +{ + #[\Override] + public static function class(): string + { + return Departement::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + */ + #[\Override] + protected function defaults(): array|callable + { + return [ + 'code' => self::faker()->randomNumber(), + 'nom' => self::faker()->text(255), + 'region' => RegionFactory::new(), + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + #[\Override] + protected function initialize(): static + { + return $this + // ->afterInstantiate(function(Departement $departement): void {}) + ; + } +} diff --git a/api-platform/api/src/Factory/RegionFactory.php b/api-platform/api/src/Factory/RegionFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..a4a6f5c48ef04222ba49edb1504491db8e1ccdd0 --- /dev/null +++ b/api-platform/api/src/Factory/RegionFactory.php @@ -0,0 +1,41 @@ + + */ +final class RegionFactory extends PersistentObjectFactory +{ + #[\Override] + public static function class(): string + { + return Region::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + */ + #[\Override] + protected function defaults(): array|callable + { + return [ + 'nom' => self::faker()->text(255), + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + #[\Override] + protected function initialize(): static + { + return $this + // ->afterInstantiate(function(Region $region): void {}) + ; + } +} diff --git a/api-platform/api/src/Factory/TaxeFactory.php b/api-platform/api/src/Factory/TaxeFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..fe410c972785dc8e88db36e0f10454b7ccdd719f --- /dev/null +++ b/api-platform/api/src/Factory/TaxeFactory.php @@ -0,0 +1,45 @@ + + */ +final class TaxeFactory extends PersistentObjectFactory +{ + #[\Override] + public static function class(): string + { + return Taxe::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + */ + #[\Override] + protected function defaults(): array|callable + { + return [ + 'annee' => self::faker()->randomNumber(), + 'commune' => CommuneFactory::new(), + 'taux' => self::faker()->randomFloat(), + 'type' => TypeTaxeFactory::new(), + 'volume' => self::faker()->randomFloat(), + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + #[\Override] + protected function initialize(): static + { + return $this + // ->afterInstantiate(function(Taxe $taxe): void {}) + ; + } +} diff --git a/api-platform/api/src/Factory/TypeTaxeFactory.php b/api-platform/api/src/Factory/TypeTaxeFactory.php new file mode 100644 index 0000000000000000000000000000000000000000..5de9dc4a23a00bf321e9006abbd9a34d5096653a --- /dev/null +++ b/api-platform/api/src/Factory/TypeTaxeFactory.php @@ -0,0 +1,42 @@ + + */ +final class TypeTaxeFactory extends PersistentObjectFactory +{ + #[\Override] + public static function class(): string + { + return TypeTaxe::class; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#model-factories + * + */ + #[\Override] + protected function defaults(): array|callable + { + return [ + 'code' => self::faker()->text(5), + 'label' => self::faker()->text(255), + ]; + } + + /** + * @see https://symfony.com/bundles/ZenstruckFoundryBundle/current/index.html#initialization + */ + #[\Override] + protected function initialize(): static + { + return $this + // ->afterInstantiate(function(TypeTaxe $typeTaxe): void {}) + ; + } +} diff --git a/api-platform/api/symfony.lock b/api-platform/api/symfony.lock index 268f2b093cff84c1ca68b237af40b0fbcc14353f..21855fdc5a26d33a24462c4e94644006276f598f 100644 --- a/api-platform/api/symfony.lock +++ b/api-platform/api/symfony.lock @@ -13,6 +13,15 @@ "src/ApiResource/.gitignore" ] }, + "dama/doctrine-test-bundle": { + "version": "8.3", + "recipe": { + "repo": "github.com/symfony/recipes-contrib", + "branch": "main", + "version": "8.3", + "ref": "dfc51177476fb39d014ed89944cde53dc3326d23" + } + }, "doctrine/deprecations": { "version": "1.1", "recipe": { @@ -261,5 +270,17 @@ "config/packages/web_profiler.yaml", "config/routes/web_profiler.yaml" ] + }, + "zenstruck/foundry": { + "version": "2.9", + "recipe": { + "repo": "github.com/symfony/recipes", + "branch": "main", + "version": "2.0", + "ref": "56bc588a1b6d5d218319f70c64c2f0fbebe30ec7" + }, + "files": [ + "config/packages/zenstruck_foundry.yaml" + ] } } diff --git a/api-platform/api/tests/Api/CommuneTest.php b/api-platform/api/tests/Api/CommuneTest.php new file mode 100644 index 0000000000000000000000000000000000000000..443c83c5fd64827bf672161e8dbe4d3fae3caffb --- /dev/null +++ b/api-platform/api/tests/Api/CommuneTest.php @@ -0,0 +1,34 @@ +request('GET', '/communes'); + + $this->assertResponseIsSuccessful(); + + // Vérifie que c'est du JSON-LD (standard API Platform) + $this->assertJsonContains([ + '@type' => 'Collection', + ]); + } + + public function testGetCommune(): void + { + $commune = CommuneFactory::createOne(); + + $response = static::createClient()->request('GET', '/communes/' . $commune->getId()); + + $this->assertResponseIsSuccessful(); + + $this->assertJsonContains([ + '@id' => '/communes/' . $commune->getId(), + ]); + } +} diff --git a/api-platform/api/tests/Api/DepartementTest.php b/api-platform/api/tests/Api/DepartementTest.php new file mode 100644 index 0000000000000000000000000000000000000000..652a703d0e866f52a0301038e7a74e3a5b5ea210 --- /dev/null +++ b/api-platform/api/tests/Api/DepartementTest.php @@ -0,0 +1,36 @@ +request('GET', '/departements'); + + $this->assertResponseIsSuccessful(); + + // Vérifie que c'est du JSON-LD (standard API Platform) + $this->assertJsonContains([ + '@type' => 'Collection', + ]); + } + + public function testGetDepartement(): void + { + $departement = DepartementFactory::createOne(); + + $response = static::createClient()->request('GET', '/departements/' . $departement->getId()); + + $this->assertResponseIsSuccessful(); + + $this->assertJsonContains([ + 'id' => $departement->getId(), + ]); + + } +} diff --git a/api-platform/api/tests/Api/GreetingsTest.php b/api-platform/api/tests/Api/GreetingsTest.php deleted file mode 100644 index acff072198b7600d0e3a98b41a35c8631d9429a3..0000000000000000000000000000000000000000 --- a/api-platform/api/tests/Api/GreetingsTest.php +++ /dev/null @@ -1,27 +0,0 @@ -request('POST', '/greetings', [ - 'json' => [ - 'name' => 'Kévin', - ], - 'headers' => [ - 'Content-Type' => 'application/ld+json', - ], - ]); - - $this->assertResponseStatusCodeSame(201); - $this->assertJsonContains([ - '@context' => '/contexts/Greeting', - '@type' => 'Greeting', - 'name' => 'Kévin', - ]); - } -} diff --git a/api-platform/api/tests/Api/RegionTest.php b/api-platform/api/tests/Api/RegionTest.php new file mode 100644 index 0000000000000000000000000000000000000000..f879fe8c3227d033b0170215c363992f2c38a383 --- /dev/null +++ b/api-platform/api/tests/Api/RegionTest.php @@ -0,0 +1,39 @@ +request('GET', '/regions'); + + $this->assertResponseIsSuccessful(); + + // Vérifie que c'est du JSON-LD (standard API Platform) + $this->assertJsonContains([ + '@type' => 'Collection', + ]); + } + + public function testGetRegion(): void + { + $region = RegionFactory::createOne(); + + $response = static::createClient()->request('GET', '/regions/' . $region->getId()); + + $this->assertResponseIsSuccessful(); + + $this->assertJsonContains([ + 'id' => $region->getId(), + ]); + + } +} +{ + +} diff --git a/api-platform/api/tests/Api/TaxeTest.php b/api-platform/api/tests/Api/TaxeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..b11d720b94acf7d2afd8f5148292cb208f5b8a2c --- /dev/null +++ b/api-platform/api/tests/Api/TaxeTest.php @@ -0,0 +1,36 @@ +request('GET', '/taxes'); + + $this->assertResponseIsSuccessful(); + + // Vérifie que c'est du JSON-LD (standard API Platform) + $this->assertJsonContains([ + '@type' => 'Collection', + ]); + } + + public function testGetTaxe(): void + { + $taxe = TaxeFactory::createOne(); + + $response = static::createClient()->request('GET', '/taxes/' . $taxe->getId()); + + $this->assertResponseIsSuccessful(); + + $this->assertJsonContains([ + 'id' => $taxe->getId(), + ]); + + } +} diff --git a/api-platform/api/tests/Api/TypeTaxeTest.php b/api-platform/api/tests/Api/TypeTaxeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..31c5d780dfa9f2af66516780612f0da451d72790 --- /dev/null +++ b/api-platform/api/tests/Api/TypeTaxeTest.php @@ -0,0 +1,39 @@ +request('GET', '/type_taxes'); + + $this->assertResponseIsSuccessful(); + + // Vérifie que c'est du JSON-LD (standard API Platform) + $this->assertJsonContains([ + '@type' => 'Collection', + ]); + } + + public function testGetTypeTaxe(): void + { + $typeTaxe = TypeTaxeFactory::createOne(); + + $response = static::createClient()->request('GET', '/type_taxes/' . $typeTaxe->getId()); + + $this->assertResponseIsSuccessful(); + + $this->assertJsonContains([ + 'id' => $typeTaxe->getId(), + ]); + + } +} +{ + +}