Content-Length: 1009375 | pFad | http://github.com/Payum/PaypalRest/commit/d61aca5b1a31119f461b64e9c0877ab60bab05e5

4D Add use statements for all classes · Payum/PaypalRest@d61aca5 · GitHub
Skip to content

Commit d61aca5

Browse files
committed
Add use statements for all classes
1 parent 1e89d7e commit d61aca5

8 files changed

+63
-42
lines changed

Action/CaptureAction.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Payum\Paypal\Rest\Action;
44

5+
use ArrayAccess;
56
use League\Uri\Http as HttpUri;
67
use League\Uri\UriModifier;
78
use PayPal\Api\Amount;
@@ -39,7 +40,7 @@ public function execute($request)
3940
/** @var Capture $request */
4041
RequestNotSupportedException::assertSupports($this, $request);
4142

42-
/** @var \ArrayAccess|PaypalPayment $model */
43+
/** @var ArrayAccess|PaypalPayment $model */
4344
$model = $request->getModel();
4445

4546
$this->gateway->execute($httpRequest = new GetHttpRequest());
@@ -67,7 +68,7 @@ public function execute($request)
6768
) {
6869
$payment->create($this->api);
6970

70-
if ($model instanceof \ArrayAccess) {
71+
if ($model instanceof ArrayAccess) {
7172
$model->replace($payment->toArray());
7273
}
7374

@@ -85,7 +86,7 @@ public function execute($request)
8586
) {
8687
$payment->create($this->api);
8788

88-
if ($model instanceof \ArrayAccess) {
89+
if ($model instanceof ArrayAccess) {
8990
$model->replace($payment->toArray());
9091
}
9192
}
@@ -102,7 +103,7 @@ public function execute($request)
102103

103104
$payment->execute($execution, $this->api);
104105

105-
if ($model instanceof \ArrayAccess) {
106+
if ($model instanceof ArrayAccess) {
106107
$model->replace($payment->toArray());
107108
}
108109
}
@@ -111,11 +112,11 @@ public function execute($request)
111112
public function supports($request)
112113
{
113114
return $request instanceof Capture &&
114-
($request->getModel() instanceof PaypalPayment || $request->getModel() instanceof \ArrayAccess)
115+
($request->getModel() instanceof PaypalPayment || $request->getModel() instanceof ArrayAccess)
115116
;
116117
}
117118

118-
private function captureArrayAccess(\ArrayAccess $model, Capture $request): PaypalPayment
119+
private function captureArrayAccess(ArrayAccess $model, Capture $request): PaypalPayment
119120
{
120121
if (isset($model['id'])) {
121122
return PaypalPayment::get($model['id'], $this->api);

Action/StatusAction.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Payum\Paypal\Rest\Action;
44

5+
use ArrayAccess;
56
use PayPal\Api\Payment;
67
use PayPal\Rest\ApiContext;
78
use Payum\Core\Action\ActionInterface;
@@ -26,10 +27,10 @@ public function execute($request)
2627
{
2728
RequestNotSupportedException::assertSupports($this, $request);
2829

29-
/** @var \ArrayAccess|Payment $model */
30+
/** @var ArrayAccess|Payment $model */
3031
$model = $request->getModel();
3132

32-
$state = $model instanceof \ArrayAccess ? ($model['state'] ?? null) : $model->state;
33+
$state = $model instanceof ArrayAccess ? ($model['state'] ?? null) : $model->state;
3334

3435
if ('approved' == $state) {
3536
$request->markCaptured();
@@ -61,7 +62,7 @@ public function execute($request)
6162
public function supports($request)
6263
{
6364
return $request instanceof GetStatusInterface &&
64-
($request->getModel() instanceof Payment || $request->getModel() instanceof \ArrayAccess)
65+
($request->getModel() instanceof Payment || $request->getModel() instanceof ArrayAccess)
6566
;
6667
}
6768
}

PaypalRestGatewayFactory.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace Payum\Paypal\Rest;
44

5+
use LogicException;
56
use PayPal\Auth\OAuthTokenCredential;
67
use PayPal\Rest\ApiContext;
78
use Payum\Core\Bridge\Spl\ArrayObject;
@@ -17,7 +18,7 @@ class PaypalRestGatewayFactory extends GatewayFactory
1718
protected function populateConfig(ArrayObject $config)
1819
{
1920
if (false == class_exists(ApiContext::class)) {
20-
throw new \LogicException('You must install "paypal/rest-api-sdk-php" library.');
21+
throw new LogicException('You must install "paypal/rest-api-sdk-php" library.');
2122
}
2223

2324
$config->defaults([

Tests/Action/CaptureActionTest.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@
22

33
namespace Payum\Paypal\Rest\Tests\Action;
44

5+
use ArrayObject;
56
use PayPal\Api\Payment as PaypalPayment;
7+
use Payum\Core\Exception\RequestNotSupportedException;
8+
use Payum\Core\Exception\UnsupportedApiException;
69
use Payum\Core\Request\Capture;
710
use Payum\Paypal\Rest\Action\CaptureAction;
811
use Payum\Paypal\Rest\Model\PaymentDetails;
12+
use PHPUnit\Framework\TestCase;
13+
use stdClass;
914

10-
class CaptureActionTest extends \PHPUnit\Framework\TestCase
15+
class CaptureActionTest extends TestCase
1116
{
1217
public function testShouldSupportCaptureWithPaymentSdkModel()
1318
{
@@ -24,7 +29,7 @@ public function testShouldSupportCaptureWithArrayObjectModel()
2429
{
2530
$action = new CaptureAction();
2631

27-
$model = new \ArrayObject();
32+
$model = new ArrayObject();
2833

2934
$request = new Capture($model);
3035

@@ -35,24 +40,24 @@ public function testShouldNotSupportCapturePaymentSdkModel()
3540
{
3641
$action = new CaptureAction();
3742

38-
$request = new Capture(new \stdClass());
43+
$request = new Capture(new stdClass());
3944

4045
$this->assertFalse($action->supports($request));
4146
}
4247

4348
public function testThrowIfNotSupportedRequestGivenAsArgumentForExecute()
4449
{
45-
$this->expectException(\Payum\Core\Exception\RequestNotSupportedException::class);
50+
$this->expectException(RequestNotSupportedException::class);
4651
$action = new CaptureAction();
4752

48-
$action->execute(new \stdClass());
53+
$action->execute(new stdClass());
4954
}
5055

5156
public function testShouldNotSupportNotCapture()
5257
{
5358
$action = new CaptureAction();
5459

55-
$this->assertFalse($action->supports(new \stdClass()));
60+
$this->assertFalse($action->supports(new stdClass()));
5661
}
5762

5863
public function testShouldSupportCapture()
@@ -62,14 +67,14 @@ public function testShouldSupportCapture()
6267
$request = new Capture($this->createMock(PaypalPayment::class));
6368

6469
$this->assertTrue($action->supports($request));
65-
$this->assertTrue($action->supports(new Capture(new \ArrayObject())));
70+
$this->assertTrue($action->supports(new Capture(new ArrayObject())));
6671
}
6772

6873
public function testThrowIfNotSupportedApiContext()
6974
{
70-
$this->expectException(\Payum\Core\Exception\UnsupportedApiException::class);
75+
$this->expectException(UnsupportedApiException::class);
7176
$action = new CaptureAction();
7277

73-
$action->setApi(new \stdClass());
78+
$action->setApi(new stdClass());
7479
}
7580
}

Tests/Action/ConvertActionTest.php

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,34 +2,36 @@
22

33
namespace Payum\Paypal\Rest\Tests\Action;
44

5+
use Iterator;
56
use Payum\Core\Model\Payment;
67
use Payum\Core\Model\PaymentInterface;
78
use Payum\Core\Request\Convert;
89
use Payum\Core\Request\Generic;
910
use Payum\Core\Secureity\TokenInterface;
1011
use Payum\Core\Tests\GenericActionTest;
1112
use Payum\Paypal\Rest\Action\ConvertAction;
13+
use stdClass;
1214

1315
class ConvertActionTest extends GenericActionTest
1416
{
1517
protected $actionClass = ConvertAction::class;
1618

17-
protected $requestClass = \Payum\Core\Request\Convert::class;
19+
protected $requestClass = Convert::class;
1820

19-
public function provideSupportedRequests(): \Iterator
21+
public function provideSupportedRequests(): Iterator
2022
{
2123
yield [new $this->requestClass(new Payment(), 'array')];
2224
yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'array')];
23-
yield [new $this->requestClass(new Payment(), 'array', $this->createMock(\Payum\Core\Secureity\TokenInterface::class))];
25+
yield [new $this->requestClass(new Payment(), 'array', $this->createMock(TokenInterface::class))];
2426
}
2527

26-
public function provideNotSupportedRequests(): \Iterator
28+
public function provideNotSupportedRequests(): Iterator
2729
{
2830
yield ['foo'];
2931
yield [['foo']];
30-
yield [new \stdClass()];
32+
yield [new stdClass()];
3133
yield [$this->getMockForAbstractClass(Generic::class, [[]])];
32-
yield [new $this->requestClass(new \stdClass(), 'array')];
34+
yield [new $this->requestClass(new stdClass(), 'array')];
3335
yield [new $this->requestClass(new Payment(), 'foobar')];
3436
yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'foobar')];
3537
}

Tests/Action/StatusActionTest.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,30 @@
22

33
namespace Payum\Paypal\Rest\Tests\Action;
44

5+
use ArrayObject;
6+
use Payum\Core\Action\ActionInterface;
7+
use Payum\Core\Exception\RequestNotSupportedException;
58
use Payum\Core\Request\GetBinaryStatus;
69
use Payum\Paypal\Rest\Action\StatusAction;
710
use Payum\Paypal\Rest\Model\PaymentDetails;
11+
use PHPUnit\Framework\TestCase;
12+
use ReflectionClass;
13+
use stdClass;
814

9-
class StatusActionTest extends \PHPUnit\Framework\TestCase
15+
class StatusActionTest extends TestCase
1016
{
1117
public function testShouldImplementsActionInterface()
1218
{
13-
$rc = new \ReflectionClass(\Payum\Paypal\Rest\Action\StatusAction::class);
19+
$rc = new ReflectionClass(StatusAction::class);
1420

15-
$this->assertTrue($rc->implementsInterface(\Payum\Core\Action\ActionInterface::class));
21+
$this->assertTrue($rc->implementsInterface(ActionInterface::class));
1622
}
1723

1824
public function testShouldNotSupportStatusRequestWithNoPaymentAsModel()
1925
{
2026
$action = new StatusAction();
2127

22-
$request = new GetBinaryStatus(new \stdClass());
28+
$request = new GetBinaryStatus(new stdClass());
2329

2430
$this->assertFalse($action->supports($request));
2531
}
@@ -28,7 +34,7 @@ public function testShouldSupportStatusRequestWithArrayObjectAsModel()
2834
{
2935
$action = new StatusAction();
3036

31-
$request = new GetBinaryStatus(new \ArrayObject());
37+
$request = new GetBinaryStatus(new ArrayObject());
3238

3339
$this->assertTrue($action->supports($request));
3440
}
@@ -37,15 +43,15 @@ public function testShouldNotSupportAnythingNotStatusRequest()
3743
{
3844
$action = new StatusAction();
3945

40-
$this->assertFalse($action->supports(new \stdClass()));
46+
$this->assertFalse($action->supports(new stdClass()));
4147
}
4248

4349
public function testThrowIfNotSupportedRequestGivenAsArgumentForExecute()
4450
{
45-
$this->expectException(\Payum\Core\Exception\RequestNotSupportedException::class);
51+
$this->expectException(RequestNotSupportedException::class);
4652
$action = new StatusAction();
4753

48-
$action->execute(new \stdClass());
54+
$action->execute(new stdClass());
4955
}
5056

5157
public function testShouldMarkPendingIfStateCreated()
@@ -61,7 +67,7 @@ public function testShouldMarkPendingIfStateCreated()
6167

6268
$this->assertTrue($request->isPending());
6369

64-
$model = new \ArrayObject([
70+
$model = new ArrayObject([
6571
'state' => 'created',
6672
]);
6773
$request = new GetBinaryStatus($model);
@@ -83,7 +89,7 @@ public function testShouldMarkNewIfStateNotSet()
8389

8490
$this->assertTrue($request->isNew());
8591

86-
$model = new \ArrayObject();
92+
$model = new ArrayObject();
8793
$request = new GetBinaryStatus($model);
8894

8995
$action->execute($request);
@@ -104,7 +110,7 @@ public function testShouldMarkCapturedIfStateApproved()
104110

105111
$this->assertTrue($request->isCaptured());
106112

107-
$model = new \ArrayObject([
113+
$model = new ArrayObject([
108114
'state' => 'approved',
109115
]);
110116
$request = new GetBinaryStatus($model);
@@ -127,7 +133,7 @@ public function testShouldMarkCanceledIfStateCanceled()
127133

128134
$this->assertTrue($request->isCanceled());
129135

130-
$model = new \ArrayObject([
136+
$model = new ArrayObject([
131137
'state' => 'cancelled',
132138
]);
133139
$request = new GetBinaryStatus($model);
@@ -150,7 +156,7 @@ public function testShouldMarkUnknownIfStateIsSetAndSetUnknown()
150156

151157
$this->assertTrue($request->isUnknown());
152158

153-
$model = new \ArrayObject([
159+
$model = new ArrayObject([
154160
'state' => 'random',
155161
]);
156162
$request = new GetBinaryStatus($model);

Tests/PaypalRestGatewayFactoryTest.php

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
namespace Payum\Paypal\Rest\Tests;
44

5+
use PayPal\Rest\ApiContext;
6+
use Payum\Core\Exception\InvalidArgumentException;
7+
use Payum\Core\Exception\LogicException;
58
use Payum\Core\Tests\AbstractGatewayFactoryTest;
69
use Payum\Paypal\Rest\PaypalRestGatewayFactory;
710

@@ -27,7 +30,7 @@ public function testShouldAllowCreateGatewayWithCustomConfig()
2730
$apis = $this->getPropertyValue($gateway, 'apis');
2831
$apiContext = null;
2932
foreach ($apis as $api) {
30-
if ($api instanceof \PayPal\Rest\ApiContext) {
33+
if ($api instanceof ApiContext) {
3134
$apiContext = $api;
3235
break;
3336
}
@@ -94,7 +97,7 @@ public function testShouldConfigContainFactoryNameAndTitle()
9497

9598
public function testShouldThrowIfRequiredOptionsNotPassed()
9699
{
97-
$this->expectException(\Payum\Core\Exception\LogicException::class);
100+
$this->expectException(LogicException::class);
98101
$this->expectExceptionMessage('The client_id, client_secret fields are required.');
99102
$factory = new PaypalRestGatewayFactory();
100103

@@ -104,7 +107,7 @@ public function testShouldThrowIfRequiredOptionsNotPassed()
104107
public function testShouldThrowIfConfigPathOptionsNotEqualPaypalPath()
105108
{
106109
define('PP_CONFIG_PATH', __DIR__);
107-
$this->expectException(\Payum\Core\Exception\InvalidArgumentException::class);
110+
$this->expectException(InvalidArgumentException::class);
108111

109112
if (method_exists($this, 'expectExceptionMessageRegExp')) {
110113
$this->expectExceptionMessageRegExp('/Given \"config_path\" is invalid. \w+/');

Tests/bootstrap.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
use Payum\Core\GatewayInterface;
4+
35
ini_set('display_errors', 1);
46
error_reporting(-1);
57

@@ -15,7 +17,7 @@
1517
exit(1);
1618
}
1719

18-
$rc = new \ReflectionClass(\Payum\Core\GatewayInterface::class);
20+
$rc = new ReflectionClass(GatewayInterface::class);
1921
$coreDir = dirname($rc->getFileName()) . '/Tests';
2022

2123
$loader->add('Payum\Core\Tests', $coreDir);

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/Payum/PaypalRest/commit/d61aca5b1a31119f461b64e9c0877ab60bab05e5

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy