Skip to content

Commit

Permalink
Adding L10 support (#18)
Browse files Browse the repository at this point in the history
* Adding L10 support
  • Loading branch information
luisdalmolin authored Oct 25, 2024
1 parent 22b5ae6 commit d4f6884
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 27 deletions.
34 changes: 30 additions & 4 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ name: run-tests

on:
push:
pull_request:

jobs:
pest:
Expand All @@ -12,8 +11,32 @@ jobs:
strategy:
fail-fast: true
matrix:
php: [ 8.2, 8.3 ]
laravel: [ 11.* ]
php: [ 8.1, 8.2, 8.3 ]
laravel: [ 10.*, 11.* ]
include:
- php: 8.1
laravel: 10.*
pest: 2.*
testbench: 8.*
- php: 8.2
laravel: 10.*
pest: 2.*
testbench: 8.*
- php: 8.3
laravel: 10.*
pest: 2.*
testbench: 8.*
- php: 8.2
laravel: 11.*
pest: 3.*
testbench: 9.*
- php: 8.3
laravel: 11.*
pest: 3.*
testbench: 9.*
exclude:
- php: 8.1
laravel: 11.*

name: Paragon Tests - PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }}

Expand All @@ -37,7 +60,10 @@ jobs:

- name: Install dependencies
run: |
composer install --no-interaction --no-suggest --dev
composer require "laravel/framework:${{ matrix.laravel }}" --no-interaction --no-update
composer require "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update --dev
composer require "pestphp/pest:${{ matrix.pest }}" "pestphp/pest-plugin-laravel:${{ matrix.pest }}" --no-interaction --no-update --dev
composer update --prefer-dist --no-interaction --no-suggest --dev
composer dump
- name: Execute tests
Expand Down
2 changes: 1 addition & 1 deletion src/Generators/EnumGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function prepareEnumCode(): Fluent
{
$cases = collect($this->reflector->getCases());

return fluent([
return new Fluent([
'type' => $this->buildTypeDefinition(),
'cases' => $this->buildCases($cases),
'getters' => $this->buildGetters($cases),
Expand Down
4 changes: 2 additions & 2 deletions tests/Architecture/AttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

use Kirschbaum\Paragon\Concerns\IgnoreParagon;

arch()->expect(IgnoreParagon::class)
arch('IgnoreParagon::Should extend nothing')->expect(IgnoreParagon::class)
->toExtendNothing();

arch()->expect(IgnoreParagon::class)
arch('IgnoreParagon::Should have attribute')->expect(IgnoreParagon::class)
->toHaveAttribute(Attribute::class);
16 changes: 10 additions & 6 deletions tests/Architecture/CommandsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

use Symfony\Component\Console\Attribute\AsCommand;

arch()->expect('Kirschbaum\Paragon\Commands')
arch('Commands should have suffix')->expect('Kirschbaum\Paragon\Commands')
->classes()
->toHaveSuffix('Command');

arch()->expect('Kirschbaum\Paragon\Commands')
arch('Commands should have attribute')->expect('Kirschbaum\Paragon\Commands')
->toHaveAttribute(AsCommand::class);

arch()->expect('Kirschbaum\Paragon\Commands')
->not->toHavePrivateMethodsBesides(['__construct', 'handle']);
exec('composer show pestphp/pest', $output);

arch()->expect('Kirschbaum\Paragon\Commands')
->not->toHavePublicMethodsBesides(['__construct', 'handle']);
if ($output[3] === 'versions : * v3') {
arch('Commands should not have private methods')->expect('Kirschbaum\Paragon\Commands')
->not->toHavePrivateMethodsBesides(['__construct', 'handle']);

arch('Commands should not have public methods')->expect('Kirschbaum\Paragon\Commands')
->not->toHavePublicMethodsBesides(['__construct', 'handle']);
}
14 changes: 9 additions & 5 deletions tests/Architecture/DiscoveryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@

use Kirschbaum\Paragon\Concerns\DiscoverEnums;

arch()->expect(DiscoverEnums::class)
arch('DiscoverEnums should extend nothing')->expect(DiscoverEnums::class)
->toExtendNothing();

arch()->expect(DiscoverEnums::class)
->not->toHavePrivateMethodsBesides(['within']);
exec('composer show pestphp/pest', $output);

arch()->expect(DiscoverEnums::class)
->not->toHavePublicMethodsBesides(['within']);
if ($output[3] === 'versions : * v3') {
arch('DiscoverEnums should not have private methods')->expect(DiscoverEnums::class)
->not->toHavePrivateMethodsBesides(['within']);

arch('DiscoverEnums should not have public methods')->expect(DiscoverEnums::class)
->not->toHavePublicMethodsBesides(['within']);
}
18 changes: 11 additions & 7 deletions tests/Architecture/GeneratorsTest.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
<?php

arch()->expect('Kirschbaum\Paragon\Generators')
arch('Generators should have suffix')->expect('Kirschbaum\Paragon\Generators')
->classes()
->toHaveSuffix('Generator');

arch()->expect('Kirschbaum\Paragon\Generators')
arch('Generators should extend nothing')->expect('Kirschbaum\Paragon\Generators')
->toExtendNothing();

arch()->expect('Kirschbaum\Paragon\Generators')
arch('Generators should be invokable')->expect('Kirschbaum\Paragon\Generators')
->toBeInvokable();

arch()->expect('Kirschbaum\Paragon\Generators')
->not->toHavePrivateMethodsBesides(['__construct', '__invoke']);
exec('composer show pestphp/pest', $output);

arch()->expect('Kirschbaum\Paragon\Generators')
->not->toHavePublicMethodsBesides(['__construct', '__invoke']);
if ($output[3] === 'versions : * v3') {
arch('Generators should not have private methods')->expect('Kirschbaum\Paragon\Generators')
->not->toHavePrivateMethodsBesides(['__construct', '__invoke']);

arch('Generators should not have public methods')->expect('Kirschbaum\Paragon\Generators')
->not->toHavePublicMethodsBesides(['__construct', '__invoke']);
}
9 changes: 7 additions & 2 deletions tests/Architecture/PresetTest.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
<?php

arch()->preset()->php();
// Pest Presets are available beginning in version 3.
exec('composer show pestphp/pest', $output);

if ($output[3] === 'versions : * v3') {
arch('PHP preset')->preset()->php();
}

// Security without the md5 method as we need it for caching.
arch()
arch('Not to use vulnerable functions')
->expect([
'array_rand',
'assert',
Expand Down
6 changes: 6 additions & 0 deletions tests/Unit/Commands/ClearCacheCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@
use Kirschbaum\Paragon\Commands\ClearCacheCommand;
use Kirschbaum\Paragon\Commands\GenerateEnumsCommand;

exec('composer show pestphp/pest', $output);

if ($output[3] !== 'versions : * v3') {
return;
}

it('removes the cache directory', function () {
// Assemble.
$this->artisan(GenerateEnumsCommand::class);
Expand Down

0 comments on commit d4f6884

Please sign in to comment.