diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f4a2df8..3dd482b 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,12 +9,17 @@ jobs: strategy: fail-fast: true matrix: - php: [8.0] - laravel: [9.*] + php: [8.0, 8.1, 8.2] + laravel: [9.*, 10.*] dependency-version: [prefer-stable] include: - laravel: 9.* testbench: 7.* + - laravel: 10.* + testbench: 8.* + exclude: + - php: '8.0' + laravel: 10.* name: PHP ${{ matrix.php }} - LARAVEL ${{ matrix.laravel }} - ${{ matrix.dependency-version }} @@ -41,4 +46,4 @@ jobs: composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "symfony/console:>=4.3.4" --no-interaction --no-update composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction - name: Execute Tests - run: ./vendor/bin/phpunit --testdox \ No newline at end of file + run: ./vendor/bin/phpunit --testdox diff --git a/.gitignore b/.gitignore index e484b50..12a94bd 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /vendor/ .idea composer.lock -.phpunit.result.cache \ No newline at end of file +.phpunit.result.cache +.phpunit.cache diff --git a/phpunit.xml b/phpunit.xml index 7aef90f..34ca597 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -1,21 +1,14 @@ - - - - ./tests - - - - - ./src - - + + + + + ./tests + + + + + ./src + + diff --git a/tests/Enums/ToolNames.php b/tests/Enums/ToolNames.php new file mode 100644 index 0000000..211668a --- /dev/null +++ b/tests/Enums/ToolNames.php @@ -0,0 +1,10 @@ +assertInstanceOf(ChildFromAbstractParent::class, $child[0]); } + + /** @test */ + function enums_can_be_used_as_type_alias() + { + if (phpversion() < 8.1) { + $this->markTestSkipped('Enums are not supported in this version of PHP'); + } + + ClawHammer::create(); + Mallet::create(); + SledgeHammer::create(); + + $tools = Tool::all(); + + $this->assertInstanceOf(ClawHammer::class, $tools[0]); + $this->assertEquals(ToolNames::ClawHammer->value, $tools[0]->type); + $this->assertInstanceOf(Mallet::class, $tools[1]); + $this->assertEquals(ToolNames::Mallet->value, $tools[1]->type); + $this->assertInstanceOf(SledgeHammer::class, $tools[2]); + $this->assertEquals(ToolNames::SledgeHammer->value, $tools[2]->type); + } } diff --git a/tests/Models/ClawHammer.php b/tests/Models/ClawHammer.php new file mode 100644 index 0000000..0e609f8 --- /dev/null +++ b/tests/Models/ClawHammer.php @@ -0,0 +1,12 @@ +value => ClawHammer::class, + ToolNames::Mallet->value => Mallet::class, + ToolNames::SledgeHammer->value => SledgeHammer::class, + ]; + } +} diff --git a/tests/TestCase.php b/tests/TestCase.php index 035986c..a1b0e60 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -104,5 +104,11 @@ public function runMigrations() $table->string('type')->nullable(); $table->timestamps(); }); + + Schema::create('tools', function ($table) { + $table->increments('id'); + $table->string('type')->nullable(); + $table->timestamps(); + }); } } diff --git a/tests/Unit/HasParentModelTest.php b/tests/Unit/HasParentTest.php similarity index 100% rename from tests/Unit/HasParentModelTest.php rename to tests/Unit/HasParentTest.php