diff --git a/.github/workflows/packagist-deploy.yml b/.github/workflows/packagist-deploy.yml index 6fea6b5..6dac033 100644 --- a/.github/workflows/packagist-deploy.yml +++ b/.github/workflows/packagist-deploy.yml @@ -2,7 +2,7 @@ name: Packagist Deploy on: release: - types: [created] + types: [ created ] jobs: build: @@ -13,8 +13,8 @@ jobs: packages: write steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v6 - uses: mnavarrocarter/packagist-update@v1.0.0 with: username: "GautierDele" - api_token: ${{ secrets.PACKAGIST_TOKEN }} \ No newline at end of file + api_token: ${{ secrets.PACKAGIST_TOKEN }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 9852101..dbcd4ce 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -14,13 +14,13 @@ jobs: strategy: fail-fast: false matrix: - php-version: [ '8.3', '8.4', '8.5' ] + php-version: [ "8.3", "8.4", "8.5" ] name: Tests on PHP ${{ matrix.php-version }} steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v6 - name: Setup PHP uses: shivammathur/setup-php@v2 @@ -33,7 +33,7 @@ jobs: - name: Cache Composer packages id: composer-cache - uses: actions/cache@v4 + uses: actions/cache@v5 with: path: vendor key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }} @@ -42,7 +42,7 @@ jobs: - name: Install dependencies if: steps.composer-cache.outputs.cache-hit != 'true' - run: composer i --prefer-dist --no-progress + run: composer i --no-progress - name: Run test suite - run: vendor/bin/phpunit \ No newline at end of file + run: vendor/bin/phpunit diff --git a/.gitignore b/.gitignore index f631e3f..159c082 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ /vendor composer.lock .phpunit* -.idea \ No newline at end of file +.idea +faker_mixin.php +packages.php diff --git a/README.md b/README.md index c762598..c810292 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ You'll be able to generate fake data for your applications, making your test env Here is a quick look at what you can do: ```php -$faker = new Xefi\Faker\Faker(); +$faker = new \Xefi\Faker\Faker(); $faker->name() // John Doe $faker->name() // Charles Brown diff --git a/composer.json b/composer.json index 44b8615..bb2903f 100644 --- a/composer.json +++ b/composer.json @@ -19,11 +19,11 @@ ], "require": { "php": ">=8.3 <8.6", - "phpdocumentor/reflection-docblock": "^5.6", + "phpdocumentor/reflection-docblock": "^5.6|^6.0", "psr/container": "^2.0" }, "require-dev": { - "phpunit/phpunit": "^11" + "phpunit/phpunit": "^12.5.23" }, "autoload": { "psr-4": { @@ -35,9 +35,6 @@ "Xefi\\Faker\\Tests\\": "tests/" } }, - "config": { - "sort-packages": true - }, "extra": { "faker": { "providers": [ @@ -47,13 +44,27 @@ }, "scripts": { "post-install-cmd": [ - "composer run generate-mixin" + "@composer run generate-mixin" ], "post-update-cmd": [ - "composer run generate-mixin" + "@composer run generate-mixin" ], "generate-mixin": [ - "php -r 'require \"vendor/autoload.php\"; (new Xefi\\Faker\\Container\\Container());'" + "@php scripts/generate-mixin.php" + ], + "test": [ + "@php vendor/bin/phpunit --colors=always" ] - } + }, + "scripts-descriptions": { + "test": "Run the PHPUnit tests.", + "generate-mixin": "Generates the IDE mixin during package installation to enable autocompletion support." + }, + "config": { + "optimize-autoloader": true, + "preferred-install": "dist", + "sort-packages": true + }, + "minimum-stability": "stable", + "prefer-stable": true } diff --git a/scripts/generate-mixin.php b/scripts/generate-mixin.php new file mode 100644 index 0000000..9e77556 --- /dev/null +++ b/scripts/generate-mixin.php @@ -0,0 +1,16 @@ +assertEquals( 'fr_FR', $faker->returnLocale() @@ -68,7 +70,7 @@ public function testUsingDefaultLocale() public function testResettingLocale() { - $faker = new Xefi\Faker\Faker('fr_FR'); + $faker = new \Xefi\Faker\Faker('fr_FR'); $this->assertEquals( 'fr_FR', $faker->returnLocale() @@ -87,7 +89,7 @@ public function testResettingLocale() public function testUsingNotExistingLocaleFallingBackToNullLocale() { - $faker = new Xefi\Faker\Faker('not-existing-locale'); + $faker = new \Xefi\Faker\Faker('not-existing-locale'); $this->assertEquals( 'default', $faker->returnLocale() @@ -108,7 +110,7 @@ public function testUsingNotExistingLocaleWithoutNullLocale() $this->expectException(\Xefi\Faker\Exceptions\NoExtensionLocaleFound::class); $this->expectExceptionMessage('Locale \'not-existing-locale\' and \'default\' for method \'returnLocale\' was not found'); - $faker = new Xefi\Faker\Faker('not-existing-locale'); + $faker = new \Xefi\Faker\Faker('not-existing-locale'); $faker->returnLocale(); } } diff --git a/tests/Unit/PackageManifestTest.php b/tests/Unit/PackageManifestTest.php index a2b29dc..fc3e1e8 100644 --- a/tests/Unit/PackageManifestTest.php +++ b/tests/Unit/PackageManifestTest.php @@ -2,8 +2,9 @@ declare(strict_types=1); +namespace Xefi\Faker\Tests\Unit; + use Xefi\Faker\Manifests\PackageManifest; -use Xefi\Faker\Tests\Unit\TestCase; final class PackageManifestTest extends TestCase { diff --git a/tests/Unit/ProviderRepositoryTest.php b/tests/Unit/ProviderRepositoryTest.php index 33c73d0..ab7cbc8 100644 --- a/tests/Unit/ProviderRepositoryTest.php +++ b/tests/Unit/ProviderRepositoryTest.php @@ -2,7 +2,7 @@ declare(strict_types=1); -use Xefi\Faker\Tests\Unit\TestCase; +namespace Xefi\Faker\Tests\Unit; final class ProviderRepositoryTest extends TestCase { diff --git a/tests/Unit/Strategies/ValidStrategyTest.php b/tests/Unit/Strategies/ValidStrategyTest.php index b8dbd9e..0e44c28 100644 --- a/tests/Unit/Strategies/ValidStrategyTest.php +++ b/tests/Unit/Strategies/ValidStrategyTest.php @@ -1,6 +1,6 @@