Skip to content
Merged
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
6 changes: 3 additions & 3 deletions .github/workflows/packagist-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Packagist Deploy

on:
release:
types: [created]
types: [ created ]

jobs:
build:
Expand All @@ -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 }}
api_token: ${{ secrets.PACKAGIST_TOKEN }}
10 changes: 5 additions & 5 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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" ]
Comment thread
martinsoenen marked this conversation as resolved.

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
Expand All @@ -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') }}
Expand All @@ -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
Comment thread
martinsoenen marked this conversation as resolved.

- name: Run test suite
run: vendor/bin/phpunit
run: vendor/bin/phpunit
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/vendor
composer.lock
.phpunit*
.idea
.idea
faker_mixin.php
packages.php
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 20 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Comment thread
ayrtonandino marked this conversation as resolved.
},
"autoload": {
"psr-4": {
Expand All @@ -35,9 +35,6 @@
"Xefi\\Faker\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"faker": {
"providers": [
Expand All @@ -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
}
16 changes: 16 additions & 0 deletions scripts/generate-mixin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/**
* Script to generate the IDE mixin for Xefi/Faker.
*
* This file is executed during Composer install/update via the "generate-mixin" script.
* It bootstraps the autoloader and instantiates the Xefi\Faker\Container\Container,
* which produces the mixin file used by supported IDEs to enable autocompletion.
*
* Running this ensures that developers get proper type hints and code completion
* when working with xefi/faker-php in their projects.
*/

require __DIR__.'/../vendor/autoload.php';

new \Xefi\Faker\Container\Container();
4 changes: 1 addition & 3 deletions tests/Unit/Extensions/GeographicalExtensionTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

namespace Extensions;

use Xefi\Faker\Tests\Unit\Extensions\TestCase;
namespace Xefi\Faker\Tests\Unit\Extensions;

final class GeographicalExtensionTest extends TestCase
{
Expand Down
10 changes: 6 additions & 4 deletions tests/Unit/LocaleTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Xefi\Faker\Tests\Unit;

class LocaleTest extends \Xefi\Faker\Tests\Unit\TestCase
{
protected function setUp(): void
Expand Down Expand Up @@ -39,7 +41,7 @@ public function testCallingDefaultExtension()

public function testUsingDefaultLocale()
{
$faker = new Xefi\Faker\Faker('fr_FR');
$faker = new \Xefi\Faker\Faker('fr_FR');
$this->assertEquals(
'fr_FR',
$faker->returnLocale()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
Expand All @@ -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();
}
}
3 changes: 2 additions & 1 deletion tests/Unit/PackageManifestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/ProviderRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

use Xefi\Faker\Tests\Unit\TestCase;
namespace Xefi\Faker\Tests\Unit;

final class ProviderRepositoryTest extends TestCase
{
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Strategies/ValidStrategyTest.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

namespace Strategies;
namespace Xefi\Faker\Tests\Unit\Strategies;

use Xefi\Faker\Faker;
use Xefi\Faker\Strategies\ValidStrategy;
Expand Down