diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index bb85a67..0dff586 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -1,5 +1,8 @@ name: Tests +permissions: + contents: read + on: [push, pull_request] jobs: @@ -20,7 +23,7 @@ jobs: steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Set up PHP ${{ matrix.php }} uses: shivammathur/setup-php@v2 @@ -29,7 +32,7 @@ jobs: coverage: xdebug - name: Install dependencies with Composer - uses: ramsey/composer-install@v2 + uses: ramsey/composer-install@v3 - name: Coding standards if: matrix.analysis @@ -44,8 +47,10 @@ jobs: - name: Upload coverage results to Coveralls if: matrix.analysis - env: - COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - composer require php-coveralls/php-coveralls -n -W - vendor/bin/php-coveralls --coverage_clover=clover.xml -v + uses: coverallsapp/github-action@v2 + with: + file: clover.xml + flag-name: php-${{ matrix.php }} + # See: https://github.com/coverallsapp/github-action?tab=readme-ov-file#complete-parallel-job-example + parallel: false # Until now only one job is set for analysis + github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/tests/ResponseTest.php b/tests/ResponseTest.php index 7bd3206..7b73488 100644 --- a/tests/ResponseTest.php +++ b/tests/ResponseTest.php @@ -141,13 +141,8 @@ public function testReasonPhraseContainsLineFeed() public function testWithStatusValidReasonPhraseObject() { - $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock(); - $mock->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('Slim OK')); - $response = new Response(); - $response = $response->withStatus(200, $mock); + $response = $response->withStatus(200, new StringableTestObject('Slim OK')); $this->assertEquals('Slim OK', $response->getReasonPhrase()); } diff --git a/tests/StringableTestObject.php b/tests/StringableTestObject.php new file mode 100644 index 0000000..36a6785 --- /dev/null +++ b/tests/StringableTestObject.php @@ -0,0 +1,23 @@ +value; + } +} diff --git a/tests/UploadedFileTest.php b/tests/UploadedFileTest.php index ec90abc..fa13a0c 100644 --- a/tests/UploadedFileTest.php +++ b/tests/UploadedFileTest.php @@ -430,7 +430,7 @@ public function testCreateUploadedFileWithInvalidUri() new UploadedFile($stream); } - public function providerCreateFromGlobals(): array + public static function providerCreateFromGlobals(): array { return [ // no nest: diff --git a/tests/UriTest.php b/tests/UriTest.php index 92077ec..aeb3a85 100644 --- a/tests/UriTest.php +++ b/tests/UriTest.php @@ -133,10 +133,7 @@ public function testWithHost() public function testWithHostValidObject() { - $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock(); - $mock->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('host.test')); + $mock = new StringableTestObject('host.test'); $uri = $this->uriFactory()->withHost($mock); $this->assertEquals('host.test', $uri->getHost()); @@ -298,10 +295,7 @@ public function testWithQueryEmpty() public function testWithQueryValidObject() { - $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock(); - $mock->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('xyz=123')); + $mock = new StringableTestObject('xyz=123'); $uri = $this->uriFactory()->withQuery($mock); $this->assertEquals('xyz=123', $uri->getQuery()); @@ -350,10 +344,7 @@ public function testWithFragmentEmpty() public function testWithFragmentValidObject() { - $mock = $this->getMockBuilder(stdClass::class)->addMethods(['__toString'])->getMock(); - $mock->expects($this->once()) - ->method('__toString') - ->will($this->returnValue('other-fragment')); + $mock = new StringableTestObject('other-fragment'); $uri = $this->uriFactory()->withFragment($mock); $this->assertEquals('other-fragment', $uri->getFragment());