diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml new file mode 100644 index 0000000..e2d86a5 --- /dev/null +++ b/.github/workflows/run-tests.yml @@ -0,0 +1,58 @@ +name: run-tests + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + test: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: true + matrix: + os: [ubuntu-latest] + php: [8.3,8.4,8.5] + laravel: [11.*,12.*] + stability: [prefer-stable] + include: + - laravel: 11.* + testbench: 9.* + - laravel: 12.* + testbench: 10.* + exclude: + - laravel: 11.* + php: 8.5 + + name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} + + steps: + - name: Checkout code + 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 + 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 }}" --no-interaction --no-update + composer update --${{ matrix.stability }} --prefer-dist --no-interaction + + - name: List Installed Dependencies + run: composer show -D + + - name: Run Security Audit + run: composer audit + + - name: Execute tests + run: vendor/bin/phpunit diff --git a/.phpunit.result.cache b/.phpunit.result.cache new file mode 100644 index 0000000..1a83542 --- /dev/null +++ b/.phpunit.result.cache @@ -0,0 +1 @@ +{"version":2,"defects":[],"times":{"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::we_can_build_authentication_endpoint_url":0.04,"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::we_can_instantiate_test_client":0.002,"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::we_can_use_a_custom_token_result_key":0.006,"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::we_can_do_a_request":0.003,"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::client_used_refreshed_token_if_a_token_is_part_of_the_response":0.003,"Code16\\MachinaClient\\Tests\\Unit\\MachinaClientTest::it_throws_an_exception_if_credentials_are_invalid":0.005}} \ No newline at end of file diff --git a/composer.json b/composer.json index 13fb431..3f87502 100755 --- a/composer.json +++ b/composer.json @@ -2,13 +2,13 @@ "name": "code16/machina-client", "description": "Client package for code16/machina", "require": { - "php": "^8.1|^8.2|^8.3|^8.4", - "illuminate/support": "^10.0|^11.0|^12.0", + "php": "^8.3|^8.4|^8.5", + "illuminate/support": "^11.0|^12.0", "guzzlehttp/guzzle": "^7.5.0" }, "require-dev": { - "phpunit/phpunit": "^9.6|^10.0|^11.0", - "orchestra/testbench": "8.*|^9.0|^10.0", + "phpunit/phpunit": "^10.0|^11.0|^12.0", + "orchestra/testbench": "^9.0|^10.0", "code16/machina": "^1.0" }, "autoload": { diff --git a/phpunit.xml b/phpunit.xml index 2d346be..5f618ee 100755 --- a/phpunit.xml +++ b/phpunit.xml @@ -11,7 +11,7 @@ > - ./tests + ./tests/Unit diff --git a/tests/Unit/MachinaClientTest.php b/tests/Unit/MachinaClientTest.php index 32d3b21..8aa39e3 100755 --- a/tests/Unit/MachinaClientTest.php +++ b/tests/Unit/MachinaClientTest.php @@ -1,16 +1,17 @@ buildTestClient(); @@ -21,13 +22,13 @@ function we_can_build_authentication_endpoint_url() ); } - /** @test */ + #[Test] function we_can_instantiate_test_client() { $this->assertInstanceOf(MachinaClient::class, $this->buildTestClient()); } - /** @test */ + #[Test] function we_can_use_a_custom_token_result_key() { config(["machina-client.token_result_key" => "toto_token"]); @@ -41,7 +42,7 @@ function we_can_use_a_custom_token_result_key() $this->assertEquals("tititata", $client->sendTokenRequest()); } - /** @test */ + #[Test] function we_can_do_a_request() { $client = $this->buildTestClient( new MockHandler([ @@ -55,7 +56,7 @@ function we_can_do_a_request() $this->assertEquals(['foo' => 'bar'], (array) $client->get('/test')); } - /** @test */ + #[Test] function client_used_refreshed_token_if_a_token_is_part_of_the_response() { $client = $this->buildTestClient( new MockHandler([ @@ -70,7 +71,7 @@ function client_used_refreshed_token_if_a_token_is_part_of_the_response() $this->assertEquals("vvvvv", $client->getToken()); } - /** @test */ + #[Test] function it_throws_an_exception_if_credentials_are_invalid() { $client = $this->buildTestClient( new MockHandler([