Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jobs:
parameters:
php-version:
type: string
default: "8.1"
default: "8.2"
executor:
name: php/php
php-version: << parameters.php-version >>
Expand All @@ -25,7 +25,7 @@ jobs:
parameters:
php-version:
type: string
default: "8.1"
default: "8.2"
executor:
name: php/php
php-version: << parameters.php-version >>
Expand All @@ -50,12 +50,12 @@ workflows:
php-version: <<matrix.php-version>>
matrix:
parameters:
php-version: [ "8.1", "8.2", "8.3", "8.4" ]
php-version: [ "8.2", "8.3", "8.4" ]
- codesniffer:
matrix:
parameters:
php-version: [ "8.1", "8.2", "8.3", "8.4" ]
php-version: [ "8.2", "8.3", "8.4" ]
- cs-fixer:
matrix:
parameters:
php-version: [ "8.1", "8.2", "8.3" ]
php-version: [ "8.2", "8.3" ]
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3",
"phpunit/phpunit": "^9.0",
"phpunit/phpunit": "^11.0",
"squizlabs/php_codesniffer": "3.*",
"phpspec/prophecy-phpunit": "^2.0"
},
Expand Down
18 changes: 12 additions & 6 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,27 @@
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
bootstrap="tests/bootstrap.php"
convertWarningsToExceptions="true"
convertNoticesToExceptions="true"
convertErrorsToExceptions="true"
backupStaticAttributes="false"
displayDetailsOnPhpunitDeprecations="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerErrors="true"
failOnNotice="true"
failOnWarning="true"
failOnDeprecation="true"
failOnPhpunitDeprecation="true"
processIsolation="false"
backupGlobals="false"
stopOnFailure="false"
colors="true"
failOnWarning="true"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
>
<coverage>
<source>
<include>
<directory>./src</directory>
</include>
</source>
<coverage>
<report>
<clover outputFile="coverage/coverage.xml"/>
<html outputDirectory="coverage" lowUpperBound="35" highLowerBound="70"/>
Expand Down
2 changes: 1 addition & 1 deletion src/Grphp/Client/Error/Status.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public static function getStatusCodeString(int $number): string
/**
* @param int $code
* @param string $details
* @param HeaderCollection $headers
* @param ?HeaderCollection $headers
*/
public function __construct(int $code, string $details, ?HeaderCollection $headers = null)
{
Expand Down
19 changes: 9 additions & 10 deletions tests/Unit/Grphp/Authentication/BasicTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,19 @@
*/
namespace Grphp\Authentication;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class BasicTest extends TestCase
{
/**
* @dataProvider providerGetMetadata
* @param array $options
*/
#[DataProvider('providerGetMetadata')]
public function testGetMetadata(array $options = [], array $expected = [])
{
$auth = new Basic($options);
$this->assertEquals($expected, $auth->getMetadata());
}
public function providerGetMetadata()

public static function providerGetMetadata()
{
return [
[ // no options
Expand All @@ -39,31 +38,31 @@ public function providerGetMetadata()
],
[ // password only
['password' => 'foo'],
['authorization' => [$this->encode('foo')]],
['authorization' => [self::encode('foo')]],
],
[ // username + password
[
'username' => 'foo',
'password' => 'bar',
],
['authorization' => [$this->encode('foo:bar')]],
['authorization' => [self::encode('foo:bar')]],
],
[ // custom metadata key
[
'username' => 'foo',
'password' => 'bar',
'metadata_key' => 'baz',
],
['baz' => [$this->encode('foo:bar')]],
['baz' => [self::encode('foo:bar')]],
]
];
}

/**]
/**
* @param string $str
* @return string
*/
private function encode(string $str)
private static function encode(string $str)
{
$s = base64_encode($str);
return "Basic $s";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
use Grphp\Client\HeaderCollection;
use Grphp\Client\Response;
use Grphp\Test\GetThingResp;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use Grphp\Client\Interceptors\Base;

Expand All @@ -42,16 +43,17 @@ protected function setUp(): void
* @param string $incomingKey
* @param string $metadataKey
* @param string $value
* @dataProvider providerMetadataInServer
*/
#[DataProvider('providerMetadataInServer')]
public function testMetadataInServer($incomingKey, $metadataKey, $value)
{
$_SERVER[$incomingKey] = $value;
$this->callInterceptor($this->interceptor);
$interceptorMetadata = $this->interceptor->getMetadata();
$this->assertEquals($value, $interceptorMetadata[$metadataKey][0]);
}
public function providerMetadataInServer()

public static function providerMetadataInServer()
{
$data = [];
foreach (ContextPropagation::METADATA_KEYS as $k => $v) {
Expand All @@ -64,16 +66,17 @@ public function providerMetadataInServer()
* @param string $incomingKey
* @param string $metadataKey
* @param string $value
* @dataProvider providerMetadataInRequest
*/
#[DataProvider('providerMetadataInRequest')]
public function testMetadataInRequest($incomingKey, $metadataKey, $value)
{
$_REQUEST[$incomingKey] = $value;
$this->callInterceptor($this->interceptor);
$interceptorMetadata = $this->interceptor->getMetadata();
$this->assertEquals($value, $interceptorMetadata[$metadataKey][0]);
}
public function providerMetadataInRequest()

public static function providerMetadataInRequest()
{
$data = [];
foreach (ContextPropagation::METADATA_KEYS as $k => $v) {
Expand All @@ -87,8 +90,8 @@ public function providerMetadataInRequest()
* @param string $metadataKey
* @param string $serverValue
* @param string $requestValue
* @dataProvider providerMetadataPrecedence
*/
#[DataProvider('providerMetadataPrecedence')]
public function testMetadataPrecedence($incomingKey, $metadataKey, $serverValue, $requestValue)
{
$_SERVER[$incomingKey] = $serverValue;
Expand All @@ -97,7 +100,8 @@ public function testMetadataPrecedence($incomingKey, $metadataKey, $serverValue,
$interceptorMetadata = $this->interceptor->getMetadata();
$this->assertEquals($requestValue, $interceptorMetadata[$metadataKey][0]);
}
public function providerMetadataPrecedence()

public static function providerMetadataPrecedence()
{
$data = [];
foreach (ContextPropagation::METADATA_KEYS as $k => $v) {
Expand Down
13 changes: 6 additions & 7 deletions tests/Unit/Grphp/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@
use Grphp\Client\Error;
use Grphp\Client\Interceptors\Base as BaseInterceptor;
use Grphp\Client\Response;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;
use Prophecy\PhpUnit\ProphecyTrait;

Expand Down Expand Up @@ -70,10 +72,8 @@ public function testAddInterceptor()
$this->assertContains($interceptorMock, $this->client->getInterceptors());
}

/**
* @depends testClearInterceptors
* @depends testAddInterceptor
*/
#[Depends('testClearInterceptors')]
#[Depends('testAddInterceptor')]
public function testGetInterceptors()
{
$this->client->clearInterceptors();
Expand All @@ -86,9 +86,8 @@ public function testGetInterceptors()

/**
* Test the call method
*
* @dataProvider providerCall
*/
#[DataProvider('providerCall')]
public function testCall($id, $isSuccess = true, $responseCode = 0, $responseDetails = '', $responseMetadata = [])
{
$opts = [
Expand Down Expand Up @@ -116,7 +115,7 @@ public function testCall($id, $isSuccess = true, $responseCode = 0, $responseDet
$this->assertEquals('Foo', $thing->getName());
}

public function providerCall()
public static function providerCall()
{
return [
[123, true, 0, 'Whoa now', ['one' => ['two']]],
Expand Down
6 changes: 4 additions & 2 deletions tests/Unit/Grphp/Serializers/Errors/JsonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
namespace Grphp\Serializers\Errors;

use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

final class JsonTest extends TestCase
Expand All @@ -32,16 +33,17 @@ protected function setUp(): void
}

/**
* @dataProvider providerDeserialize
* @param string $input
* @param array $output
*/
#[DataProvider('providerDeserialize')]
public function testDeserialize(string $input, array $output = [])
{
$o = $this->serializer->deserialize($input);
$this->assertEquals($output, $o);
}
public function providerDeserialize()

public static function providerDeserialize()
{
return [
['{"foo":123,"bar":"go!"}',['foo' => 123,'bar' => 'go!']],
Expand Down