Skip to content

Commit

Permalink
chore: update dependencies (#2)
Browse files Browse the repository at this point in the history
* chore: update deps
* chore: improve Pest configuration
* chore: edit CHANGELOG.md
  • Loading branch information
leMaur authored Apr 11, 2022
1 parent 3ec3a91 commit a2a5c14
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 10 deletions.
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

All notable changes to `toolbox` will be documented in this file.

## 3.0.0 - 2023-02-03
## 3.1.0 - 2022-04-11

- use `infection/infection` -> `dev-master` branch
- add `support` and `suggest` sections to composer.json
- improve `Pest` configuration

## 3.0.0 - 2022-02-03

- added laravel 9 support
- added new packages:
Expand Down
11 changes: 9 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
"friendsofphp/php-cs-fixer": "^v3.0",
"graham-campbell/analyzer": "^3.0",
"illuminate/contracts": "^8.0|^9.0",
"infection/infection": "^0.26.4",
"infection/infection": "dev-master",
"johnkary/phpunit-speedtrap": "^v4.0",
"laravel/dusk": "^6.0",
"nunomaduro/larastan": "^1.0|^2.0",
Expand Down Expand Up @@ -74,5 +74,12 @@
}
},
"minimum-stability": "dev",
"prefer-stable": true
"prefer-stable": true,
"support": {
"issues": "https://github.com/leMaur/toolbox/issues"
},
"suggest": {
"thecodingmachine/safe": "A set of core PHP functions rewritten to throw exceptions instead of returning false when an error is encountered.",
"thecodingmachine/phpstan-safe-rule": "PHPStan rule to help you detect unsafe function call and will propose you to use the thecodingmachine/safe variant instead."
}
}
15 changes: 8 additions & 7 deletions src/Commands/stubs/phpunit.xml.stub
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@
<testsuite name="Feature">
<directory suffix="Test.php">./tests/Feature</directory>
</testsuite>
<testsuite name="Browser">
<directory suffix="Test.php">./tests/Browser</directory>
</testsuite>
</testsuites>
<coverage processUncoveredFiles="true">
<include>
Expand All @@ -23,10 +20,14 @@
</include>
<exclude>
<!-- Framework Code -->
<!--<directory suffix=".php">./app/Actions/Fortify</directory>-->
<!--<directory suffix=".php">./app/Actions/Jetstream</directory>-->
<!--<directory suffix=".php">./app/Nova</directory>-->
<!--<file>./app/Console/Kernel.php</file>-->
<!-- <directory suffix=".php">./app/Actions/Fortify</directory>-->
<!-- <directory suffix=".php">./app/Actions/Jetstream</directory>-->
<!-- <directory suffix=".php">./app/Nova</directory>-->
<!-- <directory suffix=".php">./app/Providers</directory>-->
<!-- <file>./app/Console/Kernel.php</file>-->
<!-- <file>./app/Http/Middleware/Authenticate.php</file>-->
<!-- <file>./app/Http/Middleware/RedirectIfAuthenticated.php</file>-->
<!-- <file>./app/Http/Middleware/TrustHosts.php</file>-->
</exclude>
</coverage>
<php>
Expand Down
33 changes: 33 additions & 0 deletions src/Commands/stubs/tests/Helpers.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

declare(strict_types=1);

use App\Models\User;
use Illuminate\Contracts\Auth\Authenticatable;
use Tests\TestCase;

Expand All @@ -16,6 +17,15 @@ use Tests\TestCase;
|
*/

function actingAs(?Authenticatable $user = null): TestCase
{
if ($user === null) {
$user = User::factory()->withUuid()->create();
}

return test()->actingAs($user);
}

function actingAs(Authenticatable $user): TestCase
{
return test()->actingAs($user);
Expand All @@ -25,3 +35,26 @@ function logout(): void
{
auth()->logout();
}

/**
* @throws JsonException
* @throws InvalidArgumentException
*/
function fixture(string $name): array
{
$file = file_get_contents(
filename: base_path("tests/Fixtures/$name.json"),
);

if (! $file) {
throw new InvalidArgumentException(
message: "Cannot find fixture: [$name] at tests/Fixtures/$name.json",
);
}

return json_decode(
json: $file,
associative: true,
flags: JSON_THROW_ON_ERROR
);
}
6 changes: 6 additions & 0 deletions src/Commands/stubs/tests/Pest.php.stub
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ declare(strict_types=1);
*/

use Illuminate\Foundation\Testing\RefreshDatabase;
use Ramsey\Uuid\Uuid;
use Tests\DuskTestCase;
use Tests\TestCase;

Expand All @@ -35,3 +36,8 @@ uses(DuskTestCase::class, RefreshDatabase::class)->group('e2e')->in('Browser');
expect()->extend('toBeOne', function () {
return $this->toBe(1);
});

expect()->extend('toBeUuid4', function () {
expect($this->value)->toMatch('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/');
expect(Uuid::isValid($this->value))->toBeTrue();
});

0 comments on commit a2a5c14

Please sign in to comment.