diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b05cf2a..900f60b 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -1,19 +1,61 @@ -name: Laravel +name: run-tests on: - push: - branches: [ master ] pull_request: - branches: [ master ] - + types: [ready_for_review, synchronize] + paths: + - '**.php' + - '.github/workflows/run-tests.yml' + - 'phpunit.xml.dist' + - 'composer.json' + - 'composer.lock' jobs: - laravel-tests: + test: + runs-on: ${{ matrix.os }} + timeout-minutes: 5 + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest, windows-latest] + php: [8.5, 8.4, 8.3, 8.2] + laravel: [12.*, 13.*] + stability: [prefer-stable] + exclude: + - laravel: 13.* + php: 8.2 + include: + - laravel: 12.* + testbench: 10.* + carbon: ^3.0 + - laravel: 13.* + testbench: 11.* + carbon: ^3.0 - runs-on: ubuntu-latest + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} steps: - - uses: actions/checkout@v2 - - name: Install Dependencies - run: composer install -q --no-ansi --no-interaction --no-scripts --no-suggest --no-progress --prefer-dist - - name: Execute tests (Unit and Feature tests) via PHPUnit - run: vendor/bin/phpunit + - name: Checkout code + uses: actions/checkout@v6 + + - 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 + coverage: none + + - name: Setup problem matchers + run: | + echo "::add-matcher::${{ runner.tool_cache }}/php.json" + echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" + + - name: Install dependencies + run: | + composer require "laravel/framework:${{ matrix.laravel }}" "orchestra/testbench:${{ matrix.testbench }}" "nesbot/carbon:${{ matrix.os == 'windows-latest' && '^^^' || '' }}${{ matrix.carbon }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: List Installed Dependencies + run: composer show -D + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/tests/Filters/CastTest.php b/tests/Filters/CastTest.php index 6530366..49243dc 100644 --- a/tests/Filters/CastTest.php +++ b/tests/Filters/CastTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_throws_exception_when_no_cast_type_is_set() { $this->expectException(\InvalidArgumentException::class); $this->sanitize(['name' => 'Name'], ['name' => 'cast']); } - /** - * @test - */ + #[Test] public function it_throws_exception_when_non_existing_cast_type_is_set() { $this->expectException(\InvalidArgumentException::class); $this->sanitize(['name' => 'Name'], ['name' => 'cast:bullshit']); } - /** - * @test - */ + #[Test] public function it_casts_to_integer() { $results = $this->sanitize(['var' => '15.6'], ['var' => 'cast:integer']); @@ -45,9 +40,7 @@ public function it_casts_to_integer() $this->assertEquals(15, $results['var']); } - /** - * @test - */ + #[Test] public function it_casts_to_float() { $results = $this->sanitize(['var' => '15.6'], ['var' => 'cast:double']); @@ -55,9 +48,7 @@ public function it_casts_to_float() $this->assertEquals(15.6, $results['var']); } - /** - * @test - */ + #[Test] public function it_casts_to_string() { $results = $this->sanitize(['var' => 15], ['var' => 'cast:string']); @@ -65,9 +56,7 @@ public function it_casts_to_string() $this->assertEquals('15', $results['var']); } - /** - * @test - */ + #[Test] public function it_casts_to_boolean() { $results = $this->sanitize(['var' => 15], ['var' => 'cast:boolean']); @@ -75,9 +64,7 @@ public function it_casts_to_boolean() $this->assertEquals(true, $results['var']); } - /** - * @test - */ + #[Test] public function it_casts_array_to_object() { $data = [ @@ -91,9 +78,7 @@ public function it_casts_array_to_object() $this->assertEquals(15.6, $results['var']->cost); } - /** - * @test - */ + #[Test] public function it_casts_json_to_object() { $data = [ @@ -107,9 +92,7 @@ public function it_casts_json_to_object() $this->assertEquals(15.6, $results['var']->cost); } - /** - * @test - */ + #[Test] public function it_casts_json_to_array() { $data = [ @@ -123,9 +106,7 @@ public function it_casts_json_to_array() $this->assertEquals(15.6, $results['var']['cost']); } - /** - * @test - */ + #[Test] public function it_casts_array_to_collection() { $data = [ @@ -138,9 +119,7 @@ public function it_casts_array_to_collection() $this->assertEquals('Name', $results['var']->first()); } - /** - * @test - */ + #[Test] public function it_casts_json_to_collection() { $data = [ diff --git a/tests/Filters/DigitTest.php b/tests/Filters/DigitTest.php index aac9643..2bee2ef 100644 --- a/tests/Filters/DigitTest.php +++ b/tests/Filters/DigitTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_string_to_digits() { $data = [ @@ -32,9 +31,7 @@ public function it_string_to_digits() $this->assertEquals('080969012345', $data['name']); } - /** - * @test - */ + #[Test] public function it_string_to_digits2() { $data = [ diff --git a/tests/Filters/EscapeHTMLTest.php b/tests/Filters/EscapeHTMLTest.php index c8b3d2f..d540642 100644 --- a/tests/Filters/EscapeHTMLTest.php +++ b/tests/Filters/EscapeHTMLTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_escapes_strings() { $data = [ diff --git a/tests/Filters/FilterIfTest.php b/tests/Filters/FilterIfTest.php index acbf4fc..7fbf715 100644 --- a/tests/Filters/FilterIfTest.php +++ b/tests/Filters/FilterIfTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_apply_filter_if_match() { $data = [ @@ -32,9 +31,7 @@ public function it_apply_filter_if_match() $this->assertEquals('HELLO EVERYBODY', $data['name']); } - /** - * @test - */ + #[Test] public function it_does_not_apply_filter_if_no_match() { $data = [ diff --git a/tests/Filters/FormatDateTest.php b/tests/Filters/FormatDateTest.php index f86d84a..43ff076 100644 --- a/tests/Filters/FormatDateTest.php +++ b/tests/Filters/FormatDateTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_formats_dates() { $data = [ @@ -32,9 +31,7 @@ public function it_formats_dates() $this->assertEquals('1983-03-21', $data['name']); } - /** - * @test - */ + #[Test] public function it_requires_two_arguments() { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Filters/LowercaseTest.php b/tests/Filters/LowercaseTest.php index de91636..3c018ca 100644 --- a/tests/Filters/LowercaseTest.php +++ b/tests/Filters/LowercaseTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_lowercases_strings() { $data = [ @@ -32,9 +31,7 @@ public function it_lowercases_strings() $this->assertEquals('hello everybody', $data['name']); } - /** - * @test - */ + #[Test] public function it_lowercases_special_characters_strings() { $data = [ diff --git a/tests/Filters/StripTagsTest.php b/tests/Filters/StripTagsTest.php index 82923b2..1282c40 100644 --- a/tests/Filters/StripTagsTest.php +++ b/tests/Filters/StripTagsTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_trims_strings() { $data = [ diff --git a/tests/Filters/TrimTest.php b/tests/Filters/TrimTest.php index 2fbb770..2776144 100644 --- a/tests/Filters/TrimTest.php +++ b/tests/Filters/TrimTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_trims_strings() { $data = [ diff --git a/tests/Filters/UppercaseTest.php b/tests/Filters/UppercaseTest.php index 3489859..fe1f3c3 100644 --- a/tests/Filters/UppercaseTest.php +++ b/tests/Filters/UppercaseTest.php @@ -1,6 +1,7 @@ sanitize(); } - /** - * @test - */ + #[Test] public function it_uppercases_strings() { $data = [ @@ -32,9 +31,7 @@ public function it_uppercases_strings() $this->assertEquals('HELLO EVERYBODY', $data['name']); } - /** - * @test - */ + #[Test] public function it_uppercases_special_characters_strings() { $data = [