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

Feature/update phpunit 8 to 9 #536

Merged
merged 13 commits into from Feb 27, 2022
9 changes: 4 additions & 5 deletions .github/workflows/tests.yaml
Expand Up @@ -14,10 +14,9 @@ jobs:
fail-fast: false
matrix:
include:
- php: 7.2
- php: 7.3
- php: 7.4
- php: 8.0
- php: 8.1

steps:
- name: Checkout
Expand All @@ -43,8 +42,8 @@ jobs:
- name: Install PHP 8 dependencies
if: startsWith(matrix.php, '8')
run: |
composer req --dev --no-update payum/payum:dev-master
composer rem --dev --no-update league/uri-schemes
composer req --dev --no-update payum/payum:dev-master
composer rem --dev --no-update league/uri-schemes
pierredup marked this conversation as resolved.
Show resolved Hide resolved

- name: Install dependencies
run: composer update
Expand All @@ -60,7 +59,7 @@ jobs:
fail-fast: false
matrix:
include:
- php: 7.2
- php: 7.4

steps:
- name: Checkout
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
@@ -1,4 +1,5 @@
composer.phar
composer.lock
vendor
bin
bin
.phpunit.result.cache
15 changes: 8 additions & 7 deletions Tests/Controller/AbstractControllerTest.php
Expand Up @@ -2,6 +2,7 @@

namespace Payum\Bundle\PayumBundle\Tests\Controller;

use Payum\Core\GatewayInterface;
use Payum\Core\Model\Token;
use Payum\Core\Payum;
use Payum\Core\Registry\RegistryInterface;
Expand All @@ -16,12 +17,12 @@ abstract class AbstractControllerTest extends TestCase
protected const GATEWAY_NAME = 'theGateway';
protected const AFTER_URL = 'http://example.com/theAfterUrl';

protected $token;
protected $httpRequestVerifierMock;
protected $gatewayMock;
protected $registryMock;
protected $payum;
protected $request;
protected Token $token;
protected HttpRequestVerifierInterface $httpRequestVerifierMock;
protected GatewayInterface $gatewayMock;
protected RegistryInterface $registryMock;
pierredup marked this conversation as resolved.
Show resolved Hide resolved
protected Payum $payum;
protected Request $request;

protected function setUp(): void
{
Expand Down Expand Up @@ -63,5 +64,5 @@ protected function setUp(): void
);
}

protected abstract function initGatewayMock();
abstract protected function initGatewayMock();
}
6 changes: 3 additions & 3 deletions Tests/Controller/AuthorizeControllerTest.php
Expand Up @@ -13,7 +13,7 @@ class AuthorizeControllerTest extends AbstractControllerTest
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(AuthorizeController::class);

Expand All @@ -23,7 +23,7 @@ public function shouldBeSubClassOfController()
/**
* @test
*/
public function shouldExecuteAuthorizeRequest()
public function shouldExecuteAuthorizeRequest(): void
{
$controller = new AuthorizeController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
Expand All @@ -34,7 +34,7 @@ public function shouldExecuteAuthorizeRequest()
$this->assertEquals(self::AFTER_URL, $response->getTargetUrl());
}

protected function initGatewayMock()
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
Expand Down
8 changes: 4 additions & 4 deletions Tests/Controller/CancelControllerTest.php
Expand Up @@ -14,7 +14,7 @@ class CancelControllerTest extends AbstractControllerTest
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(CancelController::class);

Expand All @@ -24,7 +24,7 @@ public function shouldBeSubClassOfController()
/**
* @test
*/
public function shouldExecuteCancelRequest()
public function shouldExecuteCancelRequest(): void
{
$controller = new CancelController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
Expand All @@ -38,7 +38,7 @@ public function shouldExecuteCancelRequest()
/**
* @test
*/
public function shouldExecuteCancelRequestWithoutAfterUrl()
public function shouldExecuteCancelRequestWithoutAfterUrl(): void
{
$this->token->setAfterUrl(null);

Expand All @@ -51,7 +51,7 @@ public function shouldExecuteCancelRequestWithoutAfterUrl()
$this->assertEquals(204, $response->getStatusCode());
}

protected function initGatewayMock()
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
Expand Down
22 changes: 10 additions & 12 deletions Tests/Controller/CaptureControllerTest.php
Expand Up @@ -19,7 +19,7 @@ class CaptureControllerTest extends AbstractControllerTest
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(CaptureController::class);

Expand All @@ -28,12 +28,11 @@ public function shouldBeSubClassOfController()

/**
* @test
*
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @expectedExceptionMessage This controller requires session to be started.
*/
public function throwBadRequestIfSessionNotStartedOnDoSessionAction()
public function throwBadRequestIfSessionNotStartedOnDoSessionAction(): void
{
$this->expectExceptionMessage("This controller requires session to be started.");
$this->expectException(\Symfony\Component\HttpKernel\Exception\HttpException::class);
$this->registryMock = $this->createMock(RegistryInterface::class);
$this->httpRequestVerifierMock = $this->createMock(
HttpRequestVerifierInterface::class
Expand All @@ -52,12 +51,11 @@ public function throwBadRequestIfSessionNotStartedOnDoSessionAction()

/**
* @test
*
* @expectedException \Symfony\Component\HttpKernel\Exception\HttpException
* @expectedExceptionMessage This controller requires token hash to be stored in the session.
*/
public function throwBadRequestIfSessionNotContainPayumTokenOnDoSessionAction()
public function throwBadRequestIfSessionNotContainPayumTokenOnDoSessionAction(): void
{
$this->expectExceptionMessage("This controller requires token hash to be stored in the session.");
$this->expectException(\Symfony\Component\HttpKernel\Exception\HttpException::class);
$this->registryMock = $this->createMock(RegistryInterface::class);
$this->httpRequestVerifierMock = $this->createMock(
HttpRequestVerifierInterface::class
Expand All @@ -75,7 +73,7 @@ public function throwBadRequestIfSessionNotContainPayumTokenOnDoSessionAction()
/**
* @test
*/
public function shouldDoRedirectToCaptureWithTokenUrl()
public function shouldDoRedirectToCaptureWithTokenUrl(): void
{
$routerMock = $this->createMock(RouterInterface::class);
$routerMock
Expand Down Expand Up @@ -116,7 +114,7 @@ public function shouldDoRedirectToCaptureWithTokenUrl()
/**
* @test
*/
public function shouldExecuteCaptureRequest()
public function shouldExecuteCaptureRequest(): void
{
$controller = new CaptureController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
Expand All @@ -127,7 +125,7 @@ public function shouldExecuteCaptureRequest()
$this->assertEquals(self::AFTER_URL, $response->getTargetUrl());
}

protected function initGatewayMock()
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
Expand Down
4 changes: 2 additions & 2 deletions Tests/Controller/NotifyControllerTest.php
Expand Up @@ -17,7 +17,7 @@ class NotifyControllerTest extends TestCase
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(NotifyController::class);

Expand All @@ -27,7 +27,7 @@ public function shouldBeSubClassOfController()
/**
* @test
*/
public function shouldExecuteNotifyRequestOnDoUnsafe()
public function shouldExecuteNotifyRequestOnDoUnsafe(): void
{
$request = Request::create('/');
$request->query->set('gateway', 'theGatewayName');
Expand Down
6 changes: 3 additions & 3 deletions Tests/Controller/PayoutControllerTest.php
Expand Up @@ -13,7 +13,7 @@ class PayoutControllerTest extends AbstractControllerTest
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(PayoutController::class);

Expand All @@ -23,7 +23,7 @@ public function shouldBeSubClassOfController()
/**
* @test
*/
public function shouldExecutePayoutRequest()
public function shouldExecutePayoutRequest(): void
{
$controller = new PayoutController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
Expand All @@ -34,7 +34,7 @@ public function shouldExecutePayoutRequest()
$this->assertEquals(self::AFTER_URL, $response->getTargetUrl());
}

protected function initGatewayMock()
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
Expand Down
8 changes: 4 additions & 4 deletions Tests/Controller/RefundControllerTest.php
Expand Up @@ -15,7 +15,7 @@ class RefundControllerTest extends AbstractControllerTest
/**
* @test
*/
public function shouldBeSubClassOfController()
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(RefundController::class);

Expand All @@ -25,7 +25,7 @@ public function shouldBeSubClassOfController()
/**
* @test
*/
public function shouldExecuteRefundRequest()
public function shouldExecuteRefundRequest(): void
{
$controller = new RefundController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
Expand All @@ -39,7 +39,7 @@ public function shouldExecuteRefundRequest()
/**
* @test
*/
public function shouldExecuteRefundRequestWithoutAfterUrl()
public function shouldExecuteRefundRequestWithoutAfterUrl(): void
{
$this->token->setAfterUrl(null);

Expand All @@ -52,7 +52,7 @@ public function shouldExecuteRefundRequestWithoutAfterUrl()
$this->assertEquals(204, $response->getStatusCode());
}

protected function initGatewayMock()
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
Expand Down
6 changes: 3 additions & 3 deletions Tests/DependencyInjection/Compiler/BuildConfigsPassTest.php
Expand Up @@ -8,7 +8,7 @@

class BuildConfigsPassTest extends \PHPUnit\Framework\TestCase
{
public function provideTags()
public function provideTags(): array
{
return [
0 => [['name' => 'payum.action'], []],
Expand Down Expand Up @@ -182,7 +182,7 @@ public function provideTags()
];
}

public function testShouldImplementCompilerPassInterface()
public function testShouldImplementCompilerPassInterface(): void
{
$rc = new \ReflectionClass(BuildConfigsPass::class);

Expand All @@ -192,7 +192,7 @@ public function testShouldImplementCompilerPassInterface()
/**
* @dataProvider provideTags
*/
public function testShouldAddConfig(array $tagAttributes, $expected)
public function testShouldAddConfig(array $tagAttributes, $expected): void
{
$tagName = $tagAttributes['name'];
unset($tagAttributes['name']);
Expand Down
Expand Up @@ -11,14 +11,14 @@

class BuildGatewayFactoriesBuilderPassTest extends \PHPUnit\Framework\TestCase
{
public function testShouldImplementCompilerPassInterface()
public function testShouldImplementCompilerPassInterface(): void
{
$rc = new \ReflectionClass(BuildGatewayFactoriesBuilderPass::class);

$this->assertTrue($rc->implementsInterface(CompilerPassInterface::class));
}

public function testShouldAddServiceWithTagToPayumBuilder()
public function testShouldAddServiceWithTagToPayumBuilder(): void
{
$service = new Definition();
$service->addTag('payum.gateway_factory_builder', ['factory' => 'fooFactory']);
Expand All @@ -40,12 +40,10 @@ public function testShouldAddServiceWithTagToPayumBuilder()
$this->assertEquals('aservice', (string) $calls[0][1][1]);
}

/**
* @expectedException \Payum\Core\Exception\LogicException
* @expectedExceptionMessage The payum.gateway_factory tag require factory attribute.
*/
public function testThrowIfTagMissFactoryAttribute()
public function testThrowIfTagMissFactoryAttribute(): void
{
$this->expectExceptionMessage("The payum.gateway_factory tag require factory attribute.");
$this->expectException(\Payum\Core\Exception\LogicException::class);
$service = new Definition();
$service->addTag('payum.gateway_factory_builder');

Expand Down
Expand Up @@ -9,14 +9,14 @@

class BuildGatewayFactoriesPassTest extends \PHPUnit\Framework\TestCase
{
public function testShouldImplementCompilerPassInterface()
public function testShouldImplementCompilerPassInterface(): void
{
$rc = new \ReflectionClass(BuildConfigsPass::class);

$this->assertTrue($rc->implementsInterface(CompilerPassInterface::class));
}

public function testShouldAddServiceWithTagToStaticRegistry()
public function testShouldAddServiceWithTagToStaticRegistry(): void
{
$service = new Definition();
$service->addTag('payum.gateway_factory', ['factory' => 'foo']);
Expand All @@ -34,12 +34,10 @@ public function testShouldAddServiceWithTagToStaticRegistry()
$this->assertEquals(['foo' => 'aservice'], $registry->getArgument(2));
}

/**
* @expectedException \Payum\Core\Exception\LogicException
* @expectedExceptionMessage The payum.gateway_factory tag require factory attribute.
*/
public function testThrowIfTagMissFactoryAttribute()
public function testThrowIfTagMissFactoryAttribute(): void
{
$this->expectException(\Payum\Core\Exception\LogicException::class);
$this->expectExceptionMessage("The payum.gateway_factory tag require factory attribute.");
$service = new Definition();
$service->addTag('payum.gateway_factory');

Expand Down