Skip to content

Commit

Permalink
Merge pull request #145 from gsteel/phpunit-10
Browse files Browse the repository at this point in the history
Upgrade PHPUnit to version 10
  • Loading branch information
gsteel committed Mar 16, 2023
2 parents 998a9a7 + cdd9262 commit 11e96da
Show file tree
Hide file tree
Showing 17 changed files with 303 additions and 472 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/vendor
phpunit.xml
.phpunit.cache
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
"laminas/laminas-diactoros": "^2.24.0",
"php-http/curl-client": "^2.2.1",
"php-http/mock-client": "^1.5",
"phpunit/phpunit": "^9.6.5",
"phpunit/phpunit": "^10.0.16",
"psalm/plugin-phpunit": "^0.18.4",
"squizlabs/php_codesniffer": "^3.7.2",
"symfony/options-resolver": "^5.3.7 || ^6.2.7",
Expand Down
578 changes: 225 additions & 353 deletions composer.lock

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile="build/.phpunit.result.cache"
colors="true"
processIsolation="false"
stopOnFailure="false"
convertDeprecationsToExceptions="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true">
displayDetailsOnSkippedTests="true"
displayDetailsOnIncompleteTests="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerErrors="true"
cacheDirectory=".phpunit.cache">
<testsuites>
<testsuite name="Unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>

<coverage includeUncoveredFiles="true">
<include>
<directory suffix=".php">./src</directory>
</include>
</coverage>

<php>
<ini name="error_reporting" value="E_ALL" />
<ini name="error_reporting" value="E_ALL"/>
</php>
</phpunit>
12 changes: 5 additions & 7 deletions tests/Unit/ClientBehaviour/BouncesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\Bounces;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
use Postmark\Tests\Unit\ResponseFixture;

/** @link Bounces */
#[CoversClass(Bounces::class)]
class BouncesTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -25,7 +28,7 @@ protected function setUp(): void
}

/** @return array<string, array{0: string, 1: string, 2: string, 3: string}> */
public function messageRelatedMethodProvider(): array
public static function messageRelatedMethodProvider(): array
{
return [
'getBounce' => ['getBounce', 'some-id', '/bounces/some-id', 'GET'],
Expand All @@ -34,12 +37,7 @@ public function messageRelatedMethodProvider(): array
];
}

/**
* @covers \Postmark\ClientBehaviour\Bounces::getBounce
* @covers \Postmark\ClientBehaviour\Bounces::getBounceDump
* @covers \Postmark\ClientBehaviour\Bounces::activateBounce
* @dataProvider messageRelatedMethodProvider
*/
#[DataProvider('messageRelatedMethodProvider')]
public function testMessageRelatedMethods(string $method, string $messageId, string $expectPath, string $httpMethod): void
{
$this->client->$method($messageId);
Expand Down
12 changes: 5 additions & 7 deletions tests/Unit/ClientBehaviour/InboundMessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\InboundMessages;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
use Postmark\Tests\Unit\ResponseFixture;

/** @see InboundMessages */
#[CoversClass(InboundMessages::class)]
class InboundMessagesTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -25,7 +28,7 @@ protected function setUp(): void
}

/** @return array<string, array{0: string, 1: string, 2: string, 3: string}> */
public function singleStringIdArgumentMethodProvider(): array
public static function singleStringIdArgumentMethodProvider(): array
{
return [
'getInboundMessageDetails' => ['getInboundMessageDetails', 'some-id', '/messages/inbound/some-id/details', 'GET'],
Expand All @@ -34,12 +37,7 @@ public function singleStringIdArgumentMethodProvider(): array
];
}

/**
* @covers \Postmark\ClientBehaviour\InboundMessages::getInboundMessageDetails
* @covers \Postmark\ClientBehaviour\InboundMessages::bypassInboundMessageRules
* @covers \Postmark\ClientBehaviour\InboundMessages::retryInboundMessageHook
* @dataProvider singleStringIdArgumentMethodProvider
*/
#[DataProvider('singleStringIdArgumentMethodProvider')]
public function testSingleStringIdMethods(string $method, string $id, string $expectPath, string $httpMethod): void
{
$this->client->$method($id);
Expand Down
12 changes: 5 additions & 7 deletions tests/Unit/ClientBehaviour/MessageStreamsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\MessageStreams;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
use Postmark\Tests\Unit\ResponseFixture;

/** @see MessageStreams */
#[CoversClass(MessageStreams::class)]
class MessageStreamsTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -25,7 +28,7 @@ protected function setUp(): void
}

/** @return array<string, array{0: string, 1: string, 2: string, 3: string}> */
public function singleStringIdArgumentMethodProvider(): array
public static function singleStringIdArgumentMethodProvider(): array
{
return [
'getMessageStream' => ['getMessageStream', 'some-id', '/message-streams/some-id', 'GET'],
Expand All @@ -34,12 +37,7 @@ public function singleStringIdArgumentMethodProvider(): array
];
}

/**
* @covers \Postmark\ClientBehaviour\MessageStreams::getMessageStream
* @covers \Postmark\ClientBehaviour\MessageStreams::archiveMessageStream
* @covers \Postmark\ClientBehaviour\MessageStreams::unarchiveMessageStream
* @dataProvider singleStringIdArgumentMethodProvider
*/
#[DataProvider('singleStringIdArgumentMethodProvider')]
public function testSingleStringIdMethods(string $method, string $id, string $expectPath, string $httpMethod): void
{
$this->client->$method($id);
Expand Down
11 changes: 5 additions & 6 deletions tests/Unit/ClientBehaviour/OutboundMessagesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\OutboundMessages;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
Expand All @@ -12,6 +14,7 @@
use function array_keys;

/** @see OutboundMessages */
#[CoversClass(OutboundMessages::class)]
class OutboundMessagesTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -27,19 +30,15 @@ protected function setUp(): void
}

/** @return array<string, array{0: string, 1: string, 2: string, 3: string}> */
public function singleStringIdArgumentMethodProvider(): array
public static function singleStringIdArgumentMethodProvider(): array
{
return [
'getOutboundMessageDetails' => ['getOutboundMessageDetails', 'some-id', '/messages/outbound/some-id/details', 'GET'],
'getOutboundMessageDump' => ['getOutboundMessageDump', 'some-id', '/messages/outbound/some-id/dump', 'GET'],
];
}

/**
* @covers \Postmark\ClientBehaviour\OutboundMessages::getOutboundMessageDetails
* @covers \Postmark\ClientBehaviour\OutboundMessages::getOutboundMessageDump
* @dataProvider singleStringIdArgumentMethodProvider
*/
#[DataProvider('singleStringIdArgumentMethodProvider')]
public function testSingleStringIdMethods(string $method, string $id, string $expectPath, string $httpMethod): void
{
$this->client->$method($id);
Expand Down
19 changes: 7 additions & 12 deletions tests/Unit/ClientBehaviour/PostmarkClientBaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Http\Client\Exception\NetworkException;
use Http\Client\Exception\RequestException;
use Http\Client\Exception\TransferException;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\PostmarkClientBase;
use Postmark\Exception\CommunicationFailure;
use Postmark\Exception\InvalidRequestMethod;
Expand Down Expand Up @@ -73,7 +74,7 @@ public function testThatThePathWillBeAppendedToTheBaseUri(): void
}

/** @return array<string, array{0: non-empty-string}> */
public function requestBodyMethodProvider(): array
public static function requestBodyMethodProvider(): array
{
return [
RequestMethodInterface::METHOD_PUT => [RequestMethodInterface::METHOD_PUT],
Expand All @@ -83,7 +84,7 @@ public function requestBodyMethodProvider(): array
}

/** @return array<string, array{0: non-empty-string}> */
public function queryParamMethodProvider(): array
public static function queryParamMethodProvider(): array
{
return [
RequestMethodInterface::METHOD_GET => [RequestMethodInterface::METHOD_GET],
Expand All @@ -93,11 +94,8 @@ public function queryParamMethodProvider(): array
];
}

/**
* @param non-empty-string $method
*
* @dataProvider requestBodyMethodProvider
*/
/** @param non-empty-string $method */
#[DataProvider('requestBodyMethodProvider')]
public function testThatParamsAreEncodedInTheBodyWhenAppropriate(string $method): void
{
$response = ResponseFixture::fromFileName('EmptyStubResponse.json', 200)->toResponse();
Expand Down Expand Up @@ -125,11 +123,8 @@ public function testThatOnlyNullParametersAreExcludedFromTheBodyPayload(): void
$this->assertBodyParameterValueEquals('EmptyString', '');
}

/**
* @param non-empty-string $method
*
* @dataProvider queryParamMethodProvider
*/
/** @param non-empty-string $method */
#[DataProvider('queryParamMethodProvider')]
public function testThatParamsAreEncodedInTheQueryWhenAppropriate(string $method): void
{
$response = ResponseFixture::fromFileName('EmptyStubResponse.json', 200)->toResponse();
Expand Down
29 changes: 7 additions & 22 deletions tests/Unit/ClientBehaviour/StatisticsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\Statistics;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
use Postmark\Tests\Unit\ResponseFixture;

/** @link Statistics */
#[CoversClass(Statistics::class)]
class StatisticsTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -25,7 +28,7 @@ protected function setUp(): void
}

/** @return array<string, array{0: string, 1:string}> */
public function similarFourArgumentStatsMethodProvider(): array
public static function similarFourArgumentStatsMethodProvider(): array
{
return [
'getOutboundOverviewStatistics' => ['getOutboundOverviewStatistics', '/stats/outbound'],
Expand All @@ -43,22 +46,7 @@ public function similarFourArgumentStatsMethodProvider(): array
];
}

/**
* @covers \Postmark\ClientBehaviour\Statistics::stats
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundOverviewStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundSendStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundBounceStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundSpamComplaintStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundTrackedStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundOpenStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundPlatformStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundEmailClientStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundClickStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundClickBrowserFamilyStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundClickBrowserPlatformStatistics
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundClickLocationStatistics
* @dataProvider similarFourArgumentStatsMethodProvider
*/
#[DataProvider('similarFourArgumentStatsMethodProvider')]
public function testSimilarFourArgumentStatsMethods(string $method, string $expectedPath): void
{
$this->client->$method('T', 'FROM', 'TO', 'stream');
Expand All @@ -71,17 +59,14 @@ public function testSimilarFourArgumentStatsMethods(string $method, string $expe
}

/** @return array<string, array{0: string, 1:string}> */
public function similarThreeArgumentStatsMethodsProvider(): array
public static function similarThreeArgumentStatsMethodsProvider(): array
{
return [
'getOutboundReadTimeStatistics' => ['getOutboundReadTimeStatistics', '/stats/outbound/opens/readtimes'],
];
}

/**
* @covers \Postmark\ClientBehaviour\Statistics::getOutboundReadTimeStatistics
* @dataProvider similarThreeArgumentStatsMethodsProvider
*/
#[DataProvider('similarThreeArgumentStatsMethodsProvider')]
public function testSimilarThreeArgumentStatsMethods(string $method, string $expectedPath): void
{
$this->client->$method('T', 'FROM', 'TO');
Expand Down
17 changes: 6 additions & 11 deletions tests/Unit/ClientBehaviour/SuppressionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@

namespace Postmark\Tests\Unit\ClientBehaviour;

use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use Postmark\ClientBehaviour\Suppressions;
use Postmark\Models\Suppressions\SuppressionChangeRequest;
use Postmark\PostmarkClient;
use Postmark\Tests\Unit\MockClientTestCase;
use Postmark\Tests\Unit\ResponseFixture;

/** @see Suppressions */
#[CoversClass(Suppressions::class)]
class SuppressionsTest extends MockClientTestCase
{
private PostmarkClient $client;
Expand All @@ -26,7 +29,7 @@ protected function setUp(): void
}

/** @return array<array-key, array{0: string, 1: string|null, 2: string}> */
public function createAndDeleteSuppressionsDataProvider(): array
public static function createAndDeleteSuppressionsDataProvider(): array
{
return [
[
Expand All @@ -52,11 +55,7 @@ public function createAndDeleteSuppressionsDataProvider(): array
];
}

/**
* @covers \Postmark\ClientBehaviour\Suppressions::createSuppressions
* @covers \Postmark\ClientBehaviour\Suppressions::deleteSuppressions
* @dataProvider createAndDeleteSuppressionsDataProvider
*/
#[DataProvider('createAndDeleteSuppressionsDataProvider')]
public function testCreateSuppressionsWithoutList(string $method, string|null $stream, string $expectPath): void
{
if ($stream === null) {
Expand All @@ -70,11 +69,7 @@ public function testCreateSuppressionsWithoutList(string $method, string|null $s
$this->assertBodyParameterValueEquals('Suppressions', []);
}

/**
* @covers \Postmark\ClientBehaviour\Suppressions::createSuppressions
* @covers \Postmark\ClientBehaviour\Suppressions::deleteSuppressions
* @dataProvider createAndDeleteSuppressionsDataProvider
*/
#[DataProvider('createAndDeleteSuppressionsDataProvider')]
public function testCreateSuppressionsWithNonEmptySuppressionList(string $method, string|null $stream, string $expectPath): void
{
$suppression = new SuppressionChangeRequest('me@mine.com');
Expand Down

0 comments on commit 11e96da

Please sign in to comment.