Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update all dependencies #390

Merged
merged 14 commits into from
Mar 12, 2024
Merged
2 changes: 1 addition & 1 deletion .docker/PHP83-Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM php:8.3.1-fpm
FROM php:8.3.3-fpm

RUN apt-get update
RUN apt-get --yes --no-install-recommends install \
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ jobs:

- name: Upload coverage reports to Codecov
if: ${{ matrix.tool == 'code-coverage' }}
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./.phpunit.cache/clover.xml
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
"guzzlehttp/psr7": "^2",
"php-mock/php-mock-phpunit": "^2.6",
"phpstan/phpstan": "^1.10",
"phpunit/phpunit": "^9 || ^10.5"
"phpunit/phpunit": "^9.5 || ^10.5"
},
"autoload": {
"psr-4": {
Expand Down
18 changes: 9 additions & 9 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
- ./:/var/www/project/ # Location of the project for php-fpm. Note this should be the same for NGINX.*

redmine-dev:
image: redmine:5.1.1
image: redmine:5.1.2
user: "1000:1000"
ports:
- "3000:3000"
Expand All @@ -26,26 +26,26 @@ services:

# Make sure the following services are supported in /tests/RedmineExtension/RedmineInstance.php

redmine-50101:
image: redmine:5.1.1
redmine-50102:
image: redmine:5.1.2
user: "1000:1000"
ports:
- "5101:3000"
environment:
REDMINE_SECRET_KEY_BASE: supersecretkey
REDMINE_PLUGINS_MIGRATE: true
volumes:
- ./.docker/redmine-50101_data/files:/usr/src/redmine/files
- ./.docker/redmine-50101_data/sqlite:/usr/src/redmine/sqlite
- ./.docker/redmine-50102_data/files:/usr/src/redmine/files
- ./.docker/redmine-50102_data/sqlite:/usr/src/redmine/sqlite

redmine-50007:
image: redmine:5.0.7
redmine-50008:
image: redmine:5.0.8
user: "1000:1000"
ports:
- "5007:3000"
environment:
REDMINE_SECRET_KEY_BASE: supersecretkey
REDMINE_PLUGINS_MIGRATE: true
volumes:
- ./.docker/redmine-50007_data/files:/usr/src/redmine/files
- ./.docker/redmine-50007_data/sqlite:/usr/src/redmine/sqlite
- ./.docker/redmine-50008_data/files:/usr/src/redmine/files
- ./.docker/redmine-50008_data/sqlite:/usr/src/redmine/sqlite
8 changes: 4 additions & 4 deletions tests/Behat/behat.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default:
suites:
redmine_50101:
redmine_50102:
paths:
- '%paths.base%/features'
contexts:
- Redmine\Tests\Behat\Bootstrap\FeatureContext:
redmineVersion: '5.1.1'
redmine_50007:
redmineVersion: '5.1.2'
redmine_50008:
paths:
- '%paths.base%/features'
contexts:
- Redmine\Tests\Behat\Bootstrap\FeatureContext:
redmineVersion: '5.0.7'
redmineVersion: '5.0.8'
8 changes: 5 additions & 3 deletions tests/Fixtures/AssertingHttpClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Redmine\Tests\Fixtures;

use PHPUnit\Framework\MockObject\MockBuilder;
use PHPUnit\Framework\MockObject\Rule\InvokedCount;
use PHPUnit\Framework\TestCase;
use Redmine\Http\HttpClient;
use Redmine\Http\Request;
Expand All @@ -21,8 +23,8 @@ public static function create(TestCase $testCase, array $dataSet, ...$dataSets):
$dataSets = array_merge([$dataSet], $dataSets);

/** @var \PHPUnit\Framework\MockObject\MockObject&HttpClient */
$mock = $testCase->getMockBuilder(HttpClient::class)->getMock();
$mock->expects($testCase->exactly(count($dataSets)))->method('request');
$mock = (new MockBuilder($testCase, HttpClient::class))->getMock();
$mock->expects(new InvokedCount(count($dataSets)))->method('request');

$client = new self($testCase, $mock);

Expand Down Expand Up @@ -95,7 +97,7 @@ public function request(Request $request): Response
}

/** @var \PHPUnit\Framework\MockObject\MockObject&Response */
$response = $this->testCase->getMockBuilder(Response::class)->getMock();
$response = (new MockBuilder($this->testCase, Response::class))->getMock();

$response->method('getStatusCode')->willReturn($data['responseCode']);
$response->method('getContentType')->willReturn($data['responseContentType']);
Expand Down
58 changes: 28 additions & 30 deletions tests/Integration/Psr18ClientRequestGenerationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@

use GuzzleHttp\Psr7\Request;
use GuzzleHttp\Psr7\Utils;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Psr\Http\Client\ClientInterface;
use Psr\Http\Message\RequestFactoryInterface;
Expand All @@ -14,14 +16,13 @@
use Psr\Http\Message\StreamInterface;
use Redmine\Client\Psr18Client;

#[CoversClass(Psr18Client::class)]
class Psr18ClientRequestGenerationTest extends TestCase
{
/**
* @covers \Redmine\Client\Psr18Client
* @test
*
* @dataProvider createdGetRequestsData
*/
#[DataProvider('createdGetRequestsData')]
public function testPsr18ClientCreatesCorrectRequests(
string $url,
string $apikeyOrUsername,
Expand All @@ -34,42 +35,39 @@ public function testPsr18ClientCreatesCorrectRequests(
) {
$response = $this->createMock(ResponseInterface::class);

/** @var ClientInterface|\PHPUnit\Framework\MockObject\MockObject */
$httpClient = $this->createMock(ClientInterface::class);
$httpClient->method('sendRequest')->will(
$this->returnCallback(function ($request) use ($response, $expectedOutput) {
// Create a text representation of the HTTP request
$content = $request->getBody()->__toString();
$httpClient->method('sendRequest')->willReturnCallback(function ($request) use ($response, $expectedOutput) {
// Create a text representation of the HTTP request
$content = $request->getBody()->__toString();

$headers = '';
$headers = '';

foreach ($request->getHeaders() as $k => $v) {
$headers .= $k . ': ' . $request->getHeaderLine($k) . \PHP_EOL;
}
foreach ($request->getHeaders() as $k => $v) {
$headers .= $k . ': ' . $request->getHeaderLine($k) . \PHP_EOL;
}

$statusLine = sprintf(
'%s %s HTTP/%s',
$request->getMethod(),
$request->getUri()->__toString(),
$request->getProtocolVersion()
);
$statusLine = sprintf(
'%s %s HTTP/%s',
$request->getMethod(),
$request->getUri()->__toString(),
$request->getProtocolVersion()
);

$fullRequest = $statusLine . \PHP_EOL .
$headers . \PHP_EOL .
$content
;
$fullRequest = $statusLine . \PHP_EOL .
$headers . \PHP_EOL .
$content
;

$this->assertSame($expectedOutput, $fullRequest);
$this->assertSame($expectedOutput, $fullRequest);

return $response;
})
);
return $response;
});

$requestFactory = $this->createMock(RequestFactoryInterface::class);
$requestFactory->method('createRequest')->will(
$this->returnCallback(function ($method, $uri) {
return new Request($method, $uri);
})
);
$requestFactory->method('createRequest')->willReturnCallback(function ($method, $uri) {
return new Request($method, $uri);
});

$streamFactory = new class () implements StreamFactoryInterface {
public function createStream(string $content = ''): StreamInterface
Expand Down
4 changes: 2 additions & 2 deletions tests/RedmineExtension/RedmineInstance.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ final class RedmineInstance
public static function getSupportedVersions(): array
{
return [
RedmineVersion::V5_1_1,
RedmineVersion::V5_0_7,
RedmineVersion::V5_1_2,
RedmineVersion::V5_0_8,
];
}

Expand Down
17 changes: 17 additions & 0 deletions tests/RedmineExtension/RedmineVersion.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@

enum RedmineVersion: string
{
/**
* Redmine 5.1.2
*
* @link https://www.redmine.org/versions/193
* @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_1#512-2024-03-04
*/
case V5_1_2 = '5.1.2';

/**
* Redmine 5.1.1
*
Expand All @@ -22,6 +30,15 @@ enum RedmineVersion: string
*/
case V5_1_0 = '5.1.0';

/**
* Redmine 5.0.8
*
* @link https://www.redmine.org/versions/192
* @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#508-2024-03-04
*/

case V5_0_8 = '5.0.8';

/**
* Redmine 5.0.7
*
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/Api/AbstractApi/DeleteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace Redmine\Tests\Unit\Api\AbstractApi;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Redmine\Api\AbstractApi;
use Redmine\Client\Client;
use Redmine\Tests\Fixtures\AssertingHttpClient;
use ReflectionMethod;

/**
* @covers \Redmine\Api\AbstractApi::delete
*/
#[CoversClass(AbstractApi::class)]
class DeleteTest extends TestCase
{
public function testDeleteWithHttpClient()
Expand Down Expand Up @@ -44,6 +44,7 @@ public function testDeleteWithHttpClient()
/**
* @dataProvider getXmlDecodingFromDeleteMethodData
*/
#[DataProvider('getXmlDecodingFromDeleteMethodData')]
public function testXmlDecodingFromDeleteMethod($response, $expected)
{
$client = $this->createMock(Client::class);
Expand Down
8 changes: 5 additions & 3 deletions tests/Unit/Api/AbstractApi/GetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Redmine\Tests\Unit\Api\AbstractApi;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Redmine\Api\AbstractApi;
use Redmine\Client\Client;
use Redmine\Tests\Fixtures\AssertingHttpClient;
use ReflectionMethod;
use SimpleXMLElement;

/**
* @covers \Redmine\Api\AbstractApi::get
*/
#[CoversClass(AbstractApi::class)]
class GetTest extends TestCase
{
public function testGetWithHttpClient()
Expand Down Expand Up @@ -46,6 +46,7 @@ public function testGetWithHttpClient()
/**
* @dataProvider getJsonDecodingFromGetMethodData
*/
#[DataProvider('getJsonDecodingFromGetMethodData')]
public function testJsonDecodingFromGetMethod($response, $decode, $expected)
{
$client = $this->createMock(Client::class);
Expand Down Expand Up @@ -80,6 +81,7 @@ public static function getJsonDecodingFromGetMethodData(): array
/**
* @dataProvider getXmlDecodingFromGetMethodData
*/
#[DataProvider('getXmlDecodingFromGetMethodData')]
public function testXmlDecodingFromGetMethod($response, $decode, $expected)
{
$client = $this->createMock(Client::class);
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/Api/AbstractApi/PostTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Redmine\Tests\Unit\Api\AbstractApi;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Redmine\Api\AbstractApi;
use Redmine\Client\Client;
use Redmine\Tests\Fixtures\AssertingHttpClient;
use ReflectionMethod;
use SimpleXMLElement;

/**
* @covers \Redmine\Api\AbstractApi::post
*/
#[CoversClass(AbstractApi::class)]
class PostTest extends TestCase
{
public function testPostWithHttpClient()
Expand Down Expand Up @@ -46,6 +46,7 @@ public function testPostWithHttpClient()
/**
* @dataProvider getXmlDecodingFromPostMethodData
*/
#[DataProvider('getXmlDecodingFromPostMethodData')]
public function testXmlDecodingFromPostMethod($response, $expected)
{
$client = $this->createMock(Client::class);
Expand Down
7 changes: 4 additions & 3 deletions tests/Unit/Api/AbstractApi/PutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@

namespace Redmine\Tests\Unit\Api\AbstractApi;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Redmine\Api\AbstractApi;
use Redmine\Client\Client;
use Redmine\Tests\Fixtures\AssertingHttpClient;
use ReflectionMethod;
use SimpleXMLElement;

/**
* @covers \Redmine\Api\AbstractApi::put
*/
#[CoversClass(AbstractApi::class)]
class PutTest extends TestCase
{
public function testPutWithHttpClient()
Expand Down Expand Up @@ -46,6 +46,7 @@ public function testPutWithHttpClient()
/**
* @dataProvider getXmlDecodingFromPutMethodData
*/
#[DataProvider('getXmlDecodingFromPutMethodData')]
public function testXmlDecodingFromPutMethod($response, $expected)
{
$client = $this->createMock(Client::class);
Expand Down
Loading
Loading