diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 18b9bce..dcc0ebc 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,59 +1,49 @@ name: run-tests -on: - - push - - pull_request +on: [push, pull_request] jobs: test: runs-on: ubuntu-latest strategy: - fail-fast: false + fail-fast: true matrix: - php: [8.2, 8.1, 8.0] - laravel: ['8.*', '9.*', '10.*', '11.*', '12.*'] - dependency-version: [prefer-stable] + php: [8.5, 8.4, 8.3, 8.2] + laravel: ['13.*', '12.*', '11.*', '10.*'] + stability: [prefer-stable] include: - - laravel: 10.* - testbench: 8.* - - laravel: 9.* - testbench: 7.* - - laravel: 8.* - testbench: 6.* - - laravel: 11.* - testbench: 9.* + - laravel: 13.* + testbench: 11.* - laravel: 12.* testbench: 10.* + - laravel: 11.* + testbench: 9.* + - laravel: 10.* + testbench: 8.* exclude: + - laravel: 13.* + php: 8.2 - laravel: 10.* - php: 8.0 - - laravel: 11.* - php: 8.1 - - laravel: 11.* - php: 8.0 - - laravel: 12.* - php: 8.1 - - laravel: 12.* - php: 8.0 + php: 8.5 - name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.dependency-version }} + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} - extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo + extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick coverage: none - name: Install dependencies run: | composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" --no-interaction --no-update - composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction + composer update --${{ matrix.stability }} --prefer-dist --no-interaction - name: Execute tests run: vendor/bin/phpunit diff --git a/composer.json b/composer.json index 55e168a..25da779 100644 --- a/composer.json +++ b/composer.json @@ -19,17 +19,17 @@ "require": { "php": "^8.0", "ext-json": "*", - "illuminate/contracts": "^8.71|^9.0|^10.0|^11.0|^12.0", - "illuminate/filesystem": "^8.71|^9.0|^10.0|^11.0|^12.0", - "illuminate/support": "^8.71|^9.0|^10.0|^11.0|^12.0", + "illuminate/contracts": "^8.71|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/filesystem": "^8.71|^9.0|^10.0|^11.0|^12.0|^13.0", + "illuminate/support": "^8.71|^9.0|^10.0|^11.0|^12.0|^13.0", "league/commonmark": "^1.0|^2.0", "spatie/yaml-front-matter": "^2.0", "symfony/yaml": "^4.0|^5.0|^6.0|^7.0|^8.0" }, "require-dev": { "league/flysystem": "^1.0.8|^3.0", - "orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0", - "phpunit/phpunit": "^9.4|^10.5|^11.5.3" + "orchestra/testbench": "^6.23|^7.0|^8.0|^9.0|^10.0|^11.0", + "phpunit/phpunit": "^9.4|^10.5|^11.5.3|^12.5.12" }, "config": { "sort-packages": true diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 22da30c..19caab9 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,10 +1,5 @@ - - - - src/ - - + tests diff --git a/tests/ContentParsers/JsonParserTest.php b/tests/ContentParsers/JsonParserTest.php index 9ba474d..29a88ff 100644 --- a/tests/ContentParsers/JsonParserTest.php +++ b/tests/ContentParsers/JsonParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\ContentParsers\JsonParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class JsonParserTest extends TestCase { - /** @test */ + #[Test] public function it_converts_a_front_matter_document_to_attributes() { $jsonParser = $this->app->make(JsonParser::class); diff --git a/tests/ContentParsers/MarkdownParserTest.php b/tests/ContentParsers/MarkdownParserTest.php index 33f95d7..6fde139 100644 --- a/tests/ContentParsers/MarkdownParserTest.php +++ b/tests/ContentParsers/MarkdownParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\ContentParsers\MarkdownParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class MarkdownParserTest extends TestCase { - /** @test */ + #[Test] public function it_converts_a_front_matter_document_to_attributes() { $markdownParser = $this->app->make(MarkdownParser::class); diff --git a/tests/ContentParsers/MarkdownWithFrontMatterParserTest.php b/tests/ContentParsers/MarkdownWithFrontMatterParserTest.php index 33286f7..d2f6466 100644 --- a/tests/ContentParsers/MarkdownWithFrontMatterParserTest.php +++ b/tests/ContentParsers/MarkdownWithFrontMatterParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\ContentParsers\MarkdownWithFrontMatterParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class MarkdownWithFrontMatterParserTest extends TestCase { - /** @test */ + #[Test] public function it_converts_a_front_matter_document_to_attributes() { $markdownWithFrontMatterParser = $this->app->make(MarkdownWithFrontMatterParser::class); diff --git a/tests/ContentParsers/YamlParserTest.php b/tests/ContentParsers/YamlParserTest.php index e169228..9f563b3 100644 --- a/tests/ContentParsers/YamlParserTest.php +++ b/tests/ContentParsers/YamlParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\ContentParsers\YamlParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class YamlParserTest extends TestCase { - /** @test */ + #[Test] public function it_converts_a_front_matter_document_to_attributes() { $yamlParser = $this->app->make(YamlParser::class); diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php index 01a9e54..2128a8d 100644 --- a/tests/FactoryTest.php +++ b/tests/FactoryTest.php @@ -6,10 +6,11 @@ use Spatie\Sheets\ContentParsers\MarkdownWithFrontMatterParser; use Spatie\Sheets\Factory; use Spatie\Sheets\PathParsers\SlugParser; +use PHPUnit\Framework\Attributes\Test; class FactoryTest extends TestCase { - /** @test */ + #[Test] public function it_extracts_a_slug_attribute_from_a_path() { $factory = new Factory( diff --git a/tests/Integration/CustomContentParserTest.php b/tests/Integration/CustomContentParserTest.php index 6379b22..794b342 100644 --- a/tests/Integration/CustomContentParserTest.php +++ b/tests/Integration/CustomContentParserTest.php @@ -6,10 +6,11 @@ use Spatie\Sheets\ContentParsers\MarkdownParser; use Spatie\Sheets\Sheet; use Spatie\Sheets\Sheets; +use PHPUnit\Framework\Attributes\Test; class CustomContentParserTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_collection_with_a_custom_content_parser() { $documents = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/CustomDiskTest.php b/tests/Integration/CustomDiskTest.php index d1243ac..6884193 100644 --- a/tests/Integration/CustomDiskTest.php +++ b/tests/Integration/CustomDiskTest.php @@ -5,10 +5,11 @@ use Illuminate\Support\Collection; use Spatie\Sheets\Sheet; use Spatie\Sheets\Sheets; +use PHPUnit\Framework\Attributes\Test; class CustomDiskTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_collection_on_a_specific_disk() { $content = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/CustomPathParserTest.php b/tests/Integration/CustomPathParserTest.php index 432c356..57cfa01 100644 --- a/tests/Integration/CustomPathParserTest.php +++ b/tests/Integration/CustomPathParserTest.php @@ -7,10 +7,11 @@ use Spatie\Sheets\PathParsers\SlugWithDateParser; use Spatie\Sheets\Sheet; use Spatie\Sheets\Sheets; +use PHPUnit\Framework\Attributes\Test; class CustomPathParserTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_collection_with_a_custom_path_parser() { $posts = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/CustomRepositoryTest.php b/tests/Integration/CustomRepositoryTest.php index c124467..ab7d3a7 100644 --- a/tests/Integration/CustomRepositoryTest.php +++ b/tests/Integration/CustomRepositoryTest.php @@ -6,10 +6,11 @@ use Spatie\Sheets\Repository; use Spatie\Sheets\Sheet; use Spatie\Sheets\Sheets; +use PHPUnit\Framework\Attributes\Test; class CustomRepositoryTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_collection_with_a_custom_repository() { $documents = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/CustomSheetClassTest.php b/tests/Integration/CustomSheetClassTest.php index 82feb48..673133b 100644 --- a/tests/Integration/CustomSheetClassTest.php +++ b/tests/Integration/CustomSheetClassTest.php @@ -7,10 +7,11 @@ use Spatie\Sheets\PathParsers\SlugWithDateParser; use Spatie\Sheets\Sheets; use Spatie\Sheets\Tests\Integration\DummySheets\Post; +use PHPUnit\Framework\Attributes\Test; class CustomSheetClassTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_collection_with_a_custom_sheet_class() { $posts = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/DefaultConfigTest.php b/tests/Integration/DefaultConfigTest.php index eb86c00..ce0139a 100644 --- a/tests/Integration/DefaultConfigTest.php +++ b/tests/Integration/DefaultConfigTest.php @@ -5,10 +5,11 @@ use Illuminate\Support\Collection; use Spatie\Sheets\Sheet; use Spatie\Sheets\Sheets; +use PHPUnit\Framework\Attributes\Test; class DefaultConfigTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_a_default_collection() { $content = $this->app->make(Sheets::class)->all(); @@ -18,7 +19,7 @@ public function it_can_maintain_a_default_collection() $this->assertContainsOnlyInstancesOf(Sheet::class, $content); } - /** @test */ + #[Test] public function it_can_retrieve_a_default_collection_via_helper() { $content = sheets()->all(); @@ -28,7 +29,7 @@ public function it_can_retrieve_a_default_collection_via_helper() $this->assertContainsOnlyInstancesOf(Sheet::class, $content); } - /** @test */ + #[Test] public function it_can_retrieve_an_explicit_collection_via_helper() { $content = sheets('content')->all(); diff --git a/tests/Integration/ExplicitDefaultCollectionTest.php b/tests/Integration/ExplicitDefaultCollectionTest.php index 00a3be6..327ced5 100644 --- a/tests/Integration/ExplicitDefaultCollectionTest.php +++ b/tests/Integration/ExplicitDefaultCollectionTest.php @@ -6,10 +6,11 @@ use Spatie\Sheets\Sheets; use Spatie\Sheets\Tests\Integration\DummySheets\Page; use Spatie\Sheets\Tests\Integration\DummySheets\Post; +use PHPUnit\Framework\Attributes\Test; class ExplicitDefaultCollectionTest extends TestCase { - /** @test */ + #[Test] public function it_accepts_an_explicit_default_collection() { $posts = $this->app->make(Sheets::class)->all(); diff --git a/tests/Integration/ImplicitDefaultCollectionTest.php b/tests/Integration/ImplicitDefaultCollectionTest.php index bd62035..2b3007f 100644 --- a/tests/Integration/ImplicitDefaultCollectionTest.php +++ b/tests/Integration/ImplicitDefaultCollectionTest.php @@ -6,10 +6,11 @@ use Spatie\Sheets\Sheets; use Spatie\Sheets\Tests\Integration\DummySheets\Page; use Spatie\Sheets\Tests\Integration\DummySheets\Post; +use PHPUnit\Framework\Attributes\Test; class ImplicitDefaultCollectionTest extends TestCase { - /** @test */ + #[Test] public function it_defaults_to_the_first_collection_if_no_default_is_provided() { $content = $this->app->make(Sheets::class)->all(); @@ -18,7 +19,7 @@ public function it_defaults_to_the_first_collection_if_no_default_is_provided() $this->assertContainsOnlyInstancesOf(Page::class, $content); } - /** @test */ + #[Test] public function it_throws_exception_on_non_existed_collections() { $this->expectException(\RuntimeException::class); @@ -27,13 +28,13 @@ public function it_throws_exception_on_non_existed_collections() $content = $this->app->make(Sheets::class)->collection('invalid_collection'); } - /** @test */ + #[Test] public function it_can_get_null_on_the_default_collection() { $this->assertNull($this->app->make(Sheets::class)->get('non_existed_collections')); } - /** @test */ + #[Test] public function it_throws_exception_on_set_default_collection() { $this->expectException(\RuntimeException::class); diff --git a/tests/Integration/MultipleCollectionsTest.php b/tests/Integration/MultipleCollectionsTest.php index b8daa29..0be395d 100644 --- a/tests/Integration/MultipleCollectionsTest.php +++ b/tests/Integration/MultipleCollectionsTest.php @@ -7,10 +7,11 @@ use Spatie\Sheets\Sheets; use Spatie\Sheets\Tests\Integration\DummySheets\Page; use Spatie\Sheets\Tests\Integration\DummySheets\Post; +use PHPUnit\Framework\Attributes\Test; class MultipleCollectionsTest extends TestCase { - /** @test */ + #[Test] public function it_can_maintain_multiple_collections() { $content = $this->app->make(Sheets::class)->collection('content')->all(); diff --git a/tests/PathParsers/SlugParserTest.php b/tests/PathParsers/SlugParserTest.php index 80c8957..e6096a6 100644 --- a/tests/PathParsers/SlugParserTest.php +++ b/tests/PathParsers/SlugParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\PathParsers\SlugParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class SlugParserTest extends TestCase { - /** @test */ + #[Test] public function it_extracts_a_slug_attribute_from_a_path() { $slugParser = new SlugParser(); @@ -15,7 +16,7 @@ public function it_extracts_a_slug_attribute_from_a_path() $this->assertEquals(['slug' => 'hello-world'], $slugParser->parse('hello-world.md')); } - /** @test */ + #[Test] public function it_extracts_a_slug_attribute_from_a_nested_path() { $slugParser = new SlugParser(); diff --git a/tests/PathParsers/SlugWithDateParserTest.php b/tests/PathParsers/SlugWithDateParserTest.php index 50caece..c2d71a5 100644 --- a/tests/PathParsers/SlugWithDateParserTest.php +++ b/tests/PathParsers/SlugWithDateParserTest.php @@ -5,10 +5,11 @@ use Illuminate\Support\Carbon; use Spatie\Sheets\PathParsers\SlugWithDateParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class SlugWithDateParserTest extends TestCase { - /** @test */ + #[Test] public function it_extracts_a_date_and_slug_attribute_from_a_path() { $slugWithDateParser = new SlugWithDateParser(); @@ -21,7 +22,7 @@ public function it_extracts_a_date_and_slug_attribute_from_a_path() $this->assertEquals($expected, $slugWithDateParser->parse('1992-02-01.hello-world.md')); } - /** @test */ + #[Test] public function it_extracts_a_date_and_slug_attribute_from_a_nested_path() { $slugWithDateParser = new SlugWithDateParser(); diff --git a/tests/PathParsers/SlugWithOrderParserTest.php b/tests/PathParsers/SlugWithOrderParserTest.php index 668e624..fd16de8 100644 --- a/tests/PathParsers/SlugWithOrderParserTest.php +++ b/tests/PathParsers/SlugWithOrderParserTest.php @@ -4,10 +4,11 @@ use Spatie\Sheets\PathParsers\SlugWithOrderParser; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class SlugWithOrderParserTest extends TestCase { - /** @test */ + #[Test] public function it_extracts_an_order_and_slug_attribute_from_a_path() { $slugWithOrderParser = new SlugWithOrderParser(); @@ -20,7 +21,7 @@ public function it_extracts_an_order_and_slug_attribute_from_a_path() $this->assertEquals($expected, $slugWithOrderParser->parse('1.hello-world.md')); } - /** @test */ + #[Test] public function it_extracts_an_order_and_slug_attribute_from_a_nested_path() { $slugWithOrderParser = new SlugWithOrderParser(); diff --git a/tests/Repositories/FilesystemRepositoryTest.php b/tests/Repositories/FilesystemRepositoryTest.php index 29afe8c..533144a 100644 --- a/tests/Repositories/FilesystemRepositoryTest.php +++ b/tests/Repositories/FilesystemRepositoryTest.php @@ -9,13 +9,14 @@ use Spatie\Sheets\Tests\Concerns\UsesFactory; use Spatie\Sheets\Tests\Concerns\UsesFilesystem; use Spatie\Sheets\Tests\TestCase; +use PHPUnit\Framework\Attributes\Test; class FilesystemRepositoryTest extends TestCase { use UsesFactory; use UsesFilesystem; - /** @test */ + #[Test] public function it_can_get_a_sheet() { $filesystemRepository = new FilesystemRepository( @@ -31,7 +32,7 @@ public function it_can_get_a_sheet() $this->assertEquals("

Hello, world!

\n", $sheet->contents); } - /** @test */ + #[Test] public function it_can_get_all_sheets() { $filesystemRepository = new FilesystemRepository( @@ -55,7 +56,7 @@ public function it_can_get_all_sheets() $this->assertEquals("

Hello, world!

\n", $sheets[1]->contents); } - /** @test */ + #[Test] public function it_can_get_all_sheets_as_lazy_collection() { $filesystemRepository = new FilesystemRepository( @@ -79,7 +80,7 @@ public function it_can_get_all_sheets_as_lazy_collection() $this->assertEquals("

Hello, world!

\n", $sheets->get(1)->contents); } - /** @test */ + #[Test] public function it_can_get_null_on_non_existed_path() { $filesystemRepository = new FilesystemRepository( @@ -90,7 +91,7 @@ public function it_can_get_null_on_non_existed_path() $this->assertNull($filesystemRepository->get('invalid_path')); } - /** @test */ + #[Test] public function it_gets_the_same_sheet_instance() { $filesystemRepository = new FilesystemRepository( @@ -107,7 +108,7 @@ public function it_gets_the_same_sheet_instance() $this->assertSame($sheet1, $sheet2); } - /** @test */ + #[Test] public function it_can_forget_a_cached_sheet() { $filesystemRepository = new FilesystemRepository( diff --git a/tests/SheetTest.php b/tests/SheetTest.php index 7567f1c..60b6e1d 100644 --- a/tests/SheetTest.php +++ b/tests/SheetTest.php @@ -8,10 +8,11 @@ use JsonSerializable; use ReflectionClass; use Spatie\Sheets\Sheet; +use PHPUnit\Framework\Attributes\Test; class SheetTest extends TestCase { - /** @test */ + #[Test] public function it_can_create_a_sheet_with_attributes() { $attributes = [ @@ -26,7 +27,7 @@ public function it_can_create_a_sheet_with_attributes() $this->assertEquals($attributes, $reflection->getValue($sheet)); } - /** @test */ + #[Test] public function it_can_get_a_specific_attribute() { $sheet = new Sheet(['foo' => 'bar']); @@ -34,7 +35,7 @@ public function it_can_get_a_specific_attribute() $this->assertEquals('bar', $sheet->foo); } - /** @test */ + #[Test] public function it_can_get_null_for_a_non_existing_attribute() { $sheet = new Sheet(); @@ -42,7 +43,7 @@ public function it_can_get_null_for_a_non_existing_attribute() $this->assertNull($sheet->unknown); } - /** @test */ + #[Test] public function it_can_set_a_specific_attribute() { $sheet = new Sheet(); @@ -55,7 +56,7 @@ public function it_can_set_a_specific_attribute() $this->assertEquals(['foo' => 'bar'], $reflection->getValue($sheet)); } - /** @test */ + #[Test] public function it_can_be_extended_with_accessor() { $child = new class extends Sheet { @@ -71,7 +72,7 @@ public function getFooAttribute($original) $this->assertEquals('baz', $sheet->foo); } - /** @test */ + #[Test] public function it_can_be_transformed_to_array_with_accessor() { $child = new class extends Sheet { @@ -92,7 +93,7 @@ public function getFooAttribute($original) ], $sheet->toArray()); } - /** @test */ + #[Test] public function it_implements_array_access() { $sheet = new Sheet(['foo' => 'bar']); @@ -108,7 +109,7 @@ public function it_implements_array_access() $this->assertEquals('baz', $sheet['foo']); } - /** @test */ + #[Test] public function it_can_be_transformed_to_an_array() { $sheet = new Sheet(['foo' => 'bar']); @@ -117,7 +118,7 @@ public function it_can_be_transformed_to_an_array() $this->assertEquals(['foo' => 'bar'], $sheet->toArray()); } - /** @test */ + #[Test] public function it_can_be_transformed_to_json() { $sheet = new Sheet(['foo' => 'bar']); @@ -126,7 +127,7 @@ public function it_can_be_transformed_to_json() $this->assertEquals('{"foo":"bar"}', $sheet->toJson()); } - /** @test */ + #[Test] public function it_is_json_serializable() { $sheet = new Sheet(['foo' => 'bar']); @@ -135,7 +136,7 @@ public function it_is_json_serializable() $this->assertEquals('{"foo":"bar"}', json_encode($sheet)); } - /** @test */ + #[Test] public function it_serialized_to_json_when_casted_to_a_string() { $sheet = new Sheet(['foo' => 'bar']);