Skip to content

Commit 3e64c6d

Browse files
authored
Merge pull request #7 from Prometee/php-8
PHP 8 support
2 parents d6c6f43 + c570674 commit 3e64c6d

8 files changed

+33
-54
lines changed

Diff for: .github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
strategy:
2020
fail-fast: false
2121
matrix:
22-
php: [7.1, 7.2, 7.3, 7.4]
22+
php: [7.1, 7.2, 7.3, 7.4, 8.0]
2323
symfony: [^3.4, ^4.4, ^5.2]
2424
exclude:
2525
- php: 7.1

Diff for: composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,16 @@
1818
"homepage" : "https://github.com/ekyna/PayumMonetico",
1919
"license" : "MIT",
2020
"require" : {
21-
"php" : "^7.1",
21+
"php" : "^7.1|^8.0",
2222
"ext-json": "*",
2323
"payum/core": "^1.5",
2424
"psr/log": "~1.0",
2525
"symfony/options-resolver": "~3.0|~4.0|~5.0",
2626
"sokil/php-isocodes": "~2.0|~3.0"
2727
},
2828
"require-dev": {
29-
"php-http/guzzle6-adapter": "^1.1",
30-
"phpunit/phpunit": "^7"
29+
"php-http/guzzle6-adapter": "^1.1|^2.0",
30+
"phpunit/phpunit": "^7|^8|^9"
3131
},
3232
"autoload" : {
3333
"psr-4" : {

Diff for: tests/Action/AbstractActionTest.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Payum\Core\GatewayInterface;
77
use Payum\Core\Security\TokenInterface;
88
use Payum\Core\Tests\GenericActionTest;
9+
use PHPUnit\Framework\MockObject\MockObject;
910

1011
/**
1112
* Class AbstractActionTest
@@ -25,23 +26,23 @@ public function couldBeConstructedWithoutAnyArguments()
2526
}
2627

2728
/**
28-
* @return \PHPUnit_Framework_MockObject_MockObject|GatewayInterface
29+
* @return MockObject&GatewayInterface
2930
*/
3031
protected function createGatewayMock()
3132
{
3233
return $this->getMockBuilder(GatewayInterface::class)->getMock();
3334
}
3435

3536
/**
36-
* @return \PHPUnit_Framework_MockObject_MockObject|TokenInterface
37+
* @return MockObject&TokenInterface
3738
*/
3839
protected function createTokenMock()
3940
{
4041
return $this->getMockBuilder(TokenInterface::class)->getMock();
4142
}
4243

4344
/**
44-
* @return \PHPUnit_Framework_MockObject_MockObject|Api
45+
* @return MockObject&Api
4546
*/
4647
protected function createApiMock()
4748
{

Diff for: tests/Action/Api/PaymentFormActionTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ public function should_call_api_create_payment_form_and_execute_render_template(
4141
{
4242
$apiMock = $this->createApiMock();
4343
$apiMock
44-
->expects($this->at(0))
44+
->expects($this->once())
4545
->method('createPaymentForm')
4646
->with($this->isType('array'))
4747
->willReturn([]);
4848

4949
$gatewayMock = $this->createGatewayMock();
5050
$gatewayMock
51-
->expects($this->at(0))
51+
->expects($this->once())
5252
->method('execute')
5353
->with($this->isInstanceOf(RenderTemplate::class));
5454

Diff for: tests/Action/Api/PaymentResponseActionTest.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public function should_not_execute_api_check_payment_if_code_retour_not_set_in_r
2727

2828
$gatewayMock = $this->createGatewayMock();
2929
$gatewayMock
30-
->expects($this->at(0))
30+
->expects($this->once())
3131
->method('execute')
3232
->with($httpRequest);
3333

@@ -54,7 +54,7 @@ public function should_not_execute_api_check_payment_if_amount_do_not_equal()
5454
{
5555
$gatewayMock = $this->createGatewayMock();
5656
$gatewayMock
57-
->expects($this->at(0))
57+
->expects($this->once())
5858
->method('execute')
5959
->with($this->isInstanceOf(GetHttpRequest::class))
6060
->will($this->returnCallback(function (GetHttpRequest $request) {
@@ -85,7 +85,7 @@ public function should_execute_api_check_payment_if_code_retour_is_set_in_query_
8585
{
8686
$gatewayMock = $this->createGatewayMock();
8787
$gatewayMock
88-
->expects($this->at(0))
88+
->expects($this->once())
8989
->method('execute')
9090
->with($this->isInstanceOf(GetHttpRequest::class))
9191
->will($this->returnCallback(function (GetHttpRequest $request) {
@@ -95,7 +95,7 @@ public function should_execute_api_check_payment_if_code_retour_is_set_in_query_
9595

9696
$apiMock = $this->createApiMock();
9797
$apiMock
98-
->expects($this->at(0))
98+
->expects($this->once())
9999
->method('checkPaymentResponse')
100100
->with($this->isType('array'));
101101

@@ -116,7 +116,7 @@ public function should_execute_api_check_payment_if_code_retour_is_set_in_reques
116116
{
117117
$gatewayMock = $this->createGatewayMock();
118118
$gatewayMock
119-
->expects($this->at(0))
119+
->expects($this->once())
120120
->method('execute')
121121
->with($this->isInstanceOf(GetHttpRequest::class))
122122
->will($this->returnCallback(function (GetHttpRequest $request) {
@@ -126,7 +126,7 @@ public function should_execute_api_check_payment_if_code_retour_is_set_in_reques
126126

127127
$apiMock = $this->createApiMock();
128128
$apiMock
129-
->expects($this->at(0))
129+
->expects($this->once())
130130
->method('checkPaymentResponse')
131131
->with($this->isType('array'));
132132

Diff for: tests/Action/CaptureActionTest.php

+7-9
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function should_not_execute_api_request_if_urls_are_not_set()
7474
{
7575
$gatewayMock = $this->createGatewayMock();
7676
$gatewayMock
77-
->expects($this->at(0))
77+
->expects($this->once())
7878
->method('execute')
7979
->with($this->isInstanceOf(Sync::class));
8080

@@ -94,7 +94,7 @@ public function should_not_execute_api_request_if_date_is_set()
9494
{
9595
$gatewayMock = $this->createGatewayMock();
9696
$gatewayMock
97-
->expects($this->at(0))
97+
->expects($this->once())
9898
->method('execute')
9999
->with($this->isInstanceOf(Sync::class));
100100

@@ -114,14 +114,12 @@ public function should_execute_api_request_if_date_is_not_set_and_urls_are_set()
114114
{
115115
$gatewayMock = $this->createGatewayMock();
116116
$gatewayMock
117-
->expects($this->at(0))
117+
->expects($this->exactly(2))
118118
->method('execute')
119-
->with($this->isInstanceOf(PaymentForm::class));
120-
121-
$gatewayMock
122-
->expects($this->at(1))
123-
->method('execute')
124-
->with($this->isInstanceOf(Sync::class));
119+
->withConsecutive(
120+
[$this->isInstanceOf(PaymentForm::class)],
121+
[$this->isInstanceOf(Sync::class)]
122+
);
125123

126124
$action = new CaptureAction();
127125
$action->setGateway($gatewayMock);

Diff for: tests/Action/StatusActionTest.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Ekyna\Component\Payum\Monetico\Action;
44

5+
use Payum\Core\Exception\RequestNotSupportedException;
56
use Payum\Core\Request\GetHumanStatus;
67

78
/**
@@ -27,12 +28,12 @@ public function should_not_support_anything_not_status_request()
2728

2829
/**
2930
* @test
30-
*
31-
* @expectedException \Payum\Core\Exception\RequestNotSupportedException
3231
*/
3332
public function throw_if_not_supported_request()
3433
{
3534
$action = new StatusAction();
35+
36+
$this->expectException(RequestNotSupportedException::class);
3637
$action->execute(new \stdClass());
3738
}
3839

Diff for: tests/MoneticoGatewayFactoryTest.php

+7-28
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Ekyna\Component\Payum\Monetico\Api\Api;
66
use Payum\Core\CoreGatewayFactory;
77
use Payum\Core\Exception\LogicException;
8+
use Payum\Core\Gateway;
89
use Payum\Core\GatewayFactory;
910
use PHPUnit\Framework\TestCase;
1011
use ReflectionClass;
@@ -30,22 +31,6 @@ public function test_construct_without_any_arguments()
3031
$this->assertTrue(true);
3132
}
3233

33-
public function test_core_factory_created_if_not_passed()
34-
{
35-
$factory = new MoneticoGatewayFactory();
36-
37-
$this->assertAttributeInstanceOf(CoreGatewayFactory::class, 'coreGatewayFactory', $factory);
38-
}
39-
40-
public function test_core_factory_used_if_passed()
41-
{
42-
$coreFactory = $this->createMock('Payum\Core\GatewayFactoryInterface');
43-
44-
$moneticoFactory = new MoneticoGatewayFactory([], $coreFactory);
45-
46-
$this->assertAttributeSame($coreFactory, 'coreGatewayFactory', $moneticoFactory);
47-
}
48-
4934
public function test_create_gateway()
5035
{
5136
$factory = new MoneticoGatewayFactory();
@@ -57,13 +42,7 @@ public function test_create_gateway()
5742
'company' => 'foobar',
5843
]);
5944

60-
$this->assertInstanceOf('Payum\Core\Gateway', $gateway);
61-
$this->assertAttributeNotEmpty('apis', $gateway);
62-
$this->assertAttributeNotEmpty('actions', $gateway);
63-
64-
$extensions = $this->readAttribute($gateway, 'extensions');
65-
66-
$this->assertAttributeNotEmpty('extensions', $extensions);
45+
$this->assertInstanceOf(Gateway::class, $gateway);
6746
}
6847

6948
public function test_create_config()
@@ -72,7 +51,7 @@ public function test_create_config()
7251

7352
$config = $factory->createConfig();
7453

75-
$this->assertInternalType('array', $config);
54+
$this->assertIsArray($config);
7655
$this->assertNotEmpty($config);
7756
}
7857

@@ -85,7 +64,7 @@ public function test_config_defaults_passed_in_constructor()
8564

8665
$config = $factory->createConfig();
8766

88-
$this->assertInternalType('array', $config);
67+
$this->assertIsArray($config);
8968

9069
$this->assertArrayHasKey('foo', $config);
9170
$this->assertEquals('fooVal', $config['foo']);
@@ -100,7 +79,7 @@ public function test_config_contains_factory_name_and_title()
10079

10180
$config = $factory->createConfig();
10281

103-
$this->assertInternalType('array', $config);
82+
$this->assertIsArray($config);
10483

10584
$this->assertArrayHasKey('payum.factory_name', $config);
10685
$this->assertEquals('monetico', $config['payum.factory_name']);
@@ -125,10 +104,10 @@ public function test_configure_paths()
125104

126105
$config = $factory->createConfig();
127106

128-
$this->assertInternalType('array', $config);
107+
$this->assertIsArray($config);
129108
$this->assertNotEmpty($config);
130109

131-
$this->assertInternalType('array', $config['payum.paths']);
110+
$this->assertIsArray($config['payum.paths']);
132111
$this->assertNotEmpty($config['payum.paths']);
133112

134113
$this->assertArrayHasKey('PayumCore', $config['payum.paths']);

0 commit comments

Comments
 (0)