From c8e9fca7186b3ac99df3fb585217377be9dcc7d0 Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Tue, 13 Jan 2026 17:44:07 +0100 Subject: [PATCH 1/3] PHP8.5 Support --- .github/workflows/main.yml | 16 ++++++++++++++-- composer.json | 2 +- tests/Unit/Rules/EmbeddableUrlTest.php | 17 +++++++++-------- tests/Unit/ServiceBaseTest.php | 5 +++-- tests/Unit/ServiceFactoryTest.php | 7 ++++--- tests/Unit/Services/ServiceTestCase.php | 7 ++++--- tests/Unit/ValueObjects/UrlTest.php | 9 +++++---- 7 files changed, 40 insertions(+), 23 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b031e0c..5987bc1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,11 +11,11 @@ jobs: strategy: matrix: include: - - php: 8.4 + - php: 8.3 env: LARAVEL: 10.* TESTBENCH: 8.* - - php: 8.3 + - php: 8.4 env: LARAVEL: 10.* TESTBENCH: 8.* @@ -27,26 +27,38 @@ jobs: env: LARAVEL: 12.* TESTBENCH: 10.* + - php: 8.5 + env: + LARAVEL: 12.* + TESTBENCH: 10.* env: ${{ matrix.env }} steps: - uses: actions/checkout@v4 + - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: mbstring, dom, fileinfo, mysql + - name: Get composer cache directory id: composer-cache run: echo "::set-output name=dir::$(composer config cache-files-dir)" + - name: Cache composer dependencies uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} restore-keys: ${{ runner.os }}-composer- + - name: Install Composer dependencies run: | composer require "laravel/framework:${LARAVEL}" "orchestra/testbench:${TESTBENCH}" --no-interaction --no-update --prefer-dist composer update --prefer-stable --prefer-dist --no-interaction + + - name: Run Security Audit + run: composer audit + - name: Execute tests (Unit and Feature tests) via PHPUnit run: ./vendor/bin/phpunit diff --git a/composer.json b/composer.json index b12d9ef..95c065c 100644 --- a/composer.json +++ b/composer.json @@ -21,7 +21,7 @@ "laravel/framework": "^10.0|^11.0|^12.0", "laravel/pint": "^1.21", "orchestra/testbench": "^8.0|^9.0|^10.0", - "phpunit/phpunit": "^10.0|^11.0" + "phpunit/phpunit": "^10.0|^11.0|^12.0" }, "autoload": { "psr-4": { diff --git a/tests/Unit/Rules/EmbeddableUrlTest.php b/tests/Unit/Rules/EmbeddableUrlTest.php index e6ac23d..49090e6 100644 --- a/tests/Unit/Rules/EmbeddableUrlTest.php +++ b/tests/Unit/Rules/EmbeddableUrlTest.php @@ -8,10 +8,11 @@ use Code16\Embed\Services\YouTube; use Code16\Embed\Tests\EmbedTestCase; use Illuminate\Support\Facades\Validator; +use PHPUnit\Framework\Attributes\Test; class EmbeddableUrlTest extends EmbedTestCase { - /** @test */ + #[Test] public function it_passes_a_validUrl_for_any_service() { $validUrls = [ @@ -33,7 +34,7 @@ public function it_passes_a_validUrl_for_any_service() $this->assertTrue(true); } - /** @test */ + #[Test] public function it_passes_for_an_allowed_service() { $url = 'https://www.youtube.com/embed/dQw4w9WgXcQ'; @@ -52,7 +53,7 @@ public function it_passes_for_an_allowed_service() $this->assertTrue(true); } - /** @test */ + #[Test] public function it_passes_for_multiple_allowed_services() { $validUrls = [ @@ -77,7 +78,7 @@ public function it_passes_for_multiple_allowed_services() $this->assertTrue(true); } - /** @test */ + #[Test] public function it_fails_for_an_invalid_url() { $exception = null; @@ -94,7 +95,7 @@ function ($message) use (&$exception) { $this->assertNotNull($exception); } - /** @test */ + #[Test] public function it_fails_for_an_unsupported_service() { $exception = null; @@ -112,7 +113,7 @@ function ($message) use (&$exception) { $this->assertNotNull($exception); } - /** @test */ + #[Test] public function it_replaces_supported_services_in_message_with_no_services_specified() { $url = 'https://www.real.com/video/xg4y8d'; @@ -133,7 +134,7 @@ protected function assertValidationMessage($url, $rule, $expectedMessage) $this->assertEquals($expectedMessage, $validator->messages()->get($attributeKey)[0]); } - /** @test */ + #[Test] public function it_replaces_supported_service_in_message() { $url = 'https://www.real.com/video/xg4y8d'; @@ -143,7 +144,7 @@ public function it_replaces_supported_service_in_message() $this->assertValidationMessage($url, $rule, $expectedMessage); } - /** @test */ + #[Test] public function it_replaces_supported_services_list_in_message() { $url = 'https://www.real.com/video/xg4y8d'; diff --git a/tests/Unit/ServiceBaseTest.php b/tests/Unit/ServiceBaseTest.php index 759c719..d61e6b7 100644 --- a/tests/Unit/ServiceBaseTest.php +++ b/tests/Unit/ServiceBaseTest.php @@ -6,10 +6,11 @@ use Code16\Embed\Tests\Fakes\Services\FakeServiceOne; use Code16\Embed\Tests\Fakes\Services\FakeServiceTwo; use Code16\Embed\ValueObjects\Url; +use PHPUnit\Framework\Attributes\Test; class ServiceBaseTest extends EmbedTestCase { - /** @test */ + #[Test] public function it_can_guess_view_name() { $this->assertEquals( @@ -23,7 +24,7 @@ public function it_can_guess_view_name() ); } - /** @test */ + #[Test] public function it_can_pass_view_data() { $this->assertEquals( diff --git a/tests/Unit/ServiceFactoryTest.php b/tests/Unit/ServiceFactoryTest.php index e2f79de..142eb16 100644 --- a/tests/Unit/ServiceFactoryTest.php +++ b/tests/Unit/ServiceFactoryTest.php @@ -8,10 +8,11 @@ use Code16\Embed\Tests\Fakes\Services\FakeServiceOne; use Code16\Embed\Tests\Fakes\Services\FakeServiceTwo; use Code16\Embed\ValueObjects\Url; +use PHPUnit\Framework\Attributes\Test; class ServiceFactoryTest extends EmbedTestCase { - /** @test */ + #[Test] public function it_can_get_a_service_by_url() { ServiceFactory::fake(); @@ -20,7 +21,7 @@ public function it_can_get_a_service_by_url() $this->assertInstanceOf(FakeServiceTwo::class, ServiceFactory::getByUrl(new Url('https://two.com'))); } - /** @test */ + #[Test] public function it_throws_an_exception_if_no_service_exists_to_handle_the_url() { ServiceFactory::fake(); @@ -28,7 +29,7 @@ public function it_throws_an_exception_if_no_service_exists_to_handle_the_url() $this->assertNull(ServiceFactory::getByUrl(new Url('https://non-existing-service.com'))); } - /** @test */ + #[Test] public function it_can_get_a_fallback_service() { $this->assertInstanceOf(Fallback::class, diff --git a/tests/Unit/Services/ServiceTestCase.php b/tests/Unit/Services/ServiceTestCase.php index ec01186..7fc14ba 100644 --- a/tests/Unit/Services/ServiceTestCase.php +++ b/tests/Unit/Services/ServiceTestCase.php @@ -5,10 +5,11 @@ use Code16\Embed\ServiceContract; use Code16\Embed\Tests\EmbedTestCase; use Code16\Embed\ValueObjects\Url; +use PHPUnit\Framework\Attributes\Test; abstract class ServiceTestCase extends EmbedTestCase { - /** @test */ + #[Test] public function it_renders_the_correct_view() { $this->assertEquals('embed::services.'.$this->expectedViewName(), $this->service()->fullViewName()); @@ -28,7 +29,7 @@ abstract protected function serviceClass(): string; abstract protected function validUrls(): array; - /** @test */ + #[Test] public function it_detects_appropriate_urls() { foreach ($this->validUrls() as $url) { @@ -39,7 +40,7 @@ public function it_detects_appropriate_urls() } } - /** @test */ + #[Test] public function it_has_expected_view_data() { foreach ($this->expectedViewData() as $key => $value) { diff --git a/tests/Unit/ValueObjects/UrlTest.php b/tests/Unit/ValueObjects/UrlTest.php index 1542575..6095771 100644 --- a/tests/Unit/ValueObjects/UrlTest.php +++ b/tests/Unit/ValueObjects/UrlTest.php @@ -5,31 +5,32 @@ use Code16\Embed\Tests\EmbedTestCase; use Code16\Embed\ValueObjects\Url; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\Test; class UrlTest extends EmbedTestCase { - /** @test */ + #[Test] public function it_accepts_a_valid_url() { $this->assertInstanceOf(Url::class, new Url('https://example.org')); $this->assertInstanceOf(Url::class, new Url('http://example.org')); } - /** @test */ + #[Test] public function it_throws_an_exception_for_an_invalid_url() { $this->expectException(InvalidArgumentException::class); new Url('not-a-val..id-url'); } - /** @test */ + #[Test] public function it_can_be_cast_to_a_string() { $url = new Url('https://example.org'); $this->assertEquals('https://example.org', (string) $url); } - /** @test */ + #[Test] public function it_attempts_to_prepend_https_if_missing() { $url = new Url('example.org'); From 3b73c20b9b8671dc3b10b9e132132e79d0aa241f Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Tue, 13 Jan 2026 17:44:59 +0100 Subject: [PATCH 2/3] Run CI on PR --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5987bc1..e35266f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: # Unit tests back (phpunit) From 13045f23cf5f6c43495493856203b5bb6db3e170 Mon Sep 17 00:00:00 2001 From: PatrickePatate Date: Tue, 13 Jan 2026 17:49:34 +0100 Subject: [PATCH 3/3] Drop Laravel 10 Support --- .github/workflows/main.yml | 8 ++------ composer.json | 6 +++--- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e35266f..e2a5115 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,12 +16,8 @@ jobs: include: - php: 8.3 env: - LARAVEL: 10.* - TESTBENCH: 8.* - - php: 8.4 - env: - LARAVEL: 10.* - TESTBENCH: 8.* + LARAVEL: 11.* + TESTBENCH: 9.* - php: 8.4 env: LARAVEL: 11.* diff --git a/composer.json b/composer.json index 95c065c..bcea15a 100644 --- a/composer.json +++ b/composer.json @@ -13,12 +13,12 @@ "author": "Code 16", "require": { "php": "^8.0", - "illuminate/contracts": "^10.0|^11.0|^12.0", - "illuminate/support": "^10.0|^11.0|^12.0" + "illuminate/contracts": "^11.0|^12.0", + "illuminate/support": "^11.0|^12.0" }, "require-dev": { "code16/pint-config": "^1.2", - "laravel/framework": "^10.0|^11.0|^12.0", + "laravel/framework": "^11.0|^12.0", "laravel/pint": "^1.21", "orchestra/testbench": "^8.0|^9.0|^10.0", "phpunit/phpunit": "^10.0|^11.0|^12.0"