diff --git a/Action/CaptureAction.php b/Action/CaptureAction.php index 3f615d7..e78ab8b 100644 --- a/Action/CaptureAction.php +++ b/Action/CaptureAction.php @@ -2,6 +2,7 @@ namespace Payum\Be2Bill\Action; +use ArrayAccess; use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; @@ -88,7 +89,7 @@ public function execute($request) public function supports($request) { return $request instanceof Capture && - $request->getModel() instanceof \ArrayAccess + $request->getModel() instanceof ArrayAccess ; } } diff --git a/Action/CaptureOffsiteAction.php b/Action/CaptureOffsiteAction.php index e6a83ca..85ec56d 100644 --- a/Action/CaptureOffsiteAction.php +++ b/Action/CaptureOffsiteAction.php @@ -2,6 +2,7 @@ namespace Payum\Be2Bill\Action; +use ArrayAccess; use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; @@ -73,7 +74,7 @@ public function execute($request) public function supports($request) { return $request instanceof Capture && - $request->getModel() instanceof \ArrayAccess + $request->getModel() instanceof ArrayAccess ; } } diff --git a/Action/NotifyAction.php b/Action/NotifyAction.php index d98fe91..6fe4099 100644 --- a/Action/NotifyAction.php +++ b/Action/NotifyAction.php @@ -2,6 +2,7 @@ namespace Payum\Be2Bill\Action; +use ArrayAccess; use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; @@ -51,7 +52,7 @@ public function execute($request) public function supports($request) { return $request instanceof Notify && - $request->getModel() instanceof \ArrayAccess + $request->getModel() instanceof ArrayAccess ; } } diff --git a/Action/StatusAction.php b/Action/StatusAction.php index 829b64c..973022c 100644 --- a/Action/StatusAction.php +++ b/Action/StatusAction.php @@ -2,6 +2,7 @@ namespace Payum\Be2Bill\Action; +use ArrayAccess; use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\Bridge\Spl\ArrayObject; @@ -43,7 +44,7 @@ public function execute($request) public function supports($request) { return $request instanceof GetStatusInterface && - $request->getModel() instanceof \ArrayAccess + $request->getModel() instanceof ArrayAccess ; } } diff --git a/Api.php b/Api.php index c20af52..dc5e403 100644 --- a/Api.php +++ b/Api.php @@ -5,6 +5,7 @@ use Http\Message\MessageFactory; use Payum\Core\Bridge\Spl\ArrayObject; use Payum\Core\Exception\Http\HttpException; +use Payum\Core\Exception\InvalidArgumentException; use Payum\Core\Exception\LogicException; use Payum\Core\HttpClientInterface; @@ -122,7 +123,7 @@ class Api ]; /** - * @throws \Payum\Core\Exception\InvalidArgumentException if an option is invalid + * @throws InvalidArgumentException if an option is invalid */ public function __construct(array $options, HttpClientInterface $client, MessageFactory $messageFactory) { diff --git a/Tests/Action/CaptureActionTest.php b/Tests/Action/CaptureActionTest.php index 5a48754..820b0df 100644 --- a/Tests/Action/CaptureActionTest.php +++ b/Tests/Action/CaptureActionTest.php @@ -2,11 +2,15 @@ namespace Payum\Be2Bill\Tests\Action; +use ArrayObject; +use DateTime; use Payum\Be2Bill\Action\CaptureAction; use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; +use Payum\Core\Exception\LogicException; use Payum\Core\Exception\RequestNotSupportedException; +use Payum\Core\Exception\UnsupportedApiException; use Payum\Core\GatewayAwareInterface; use Payum\Core\GatewayInterface; use Payum\Core\Model\CreditCard; @@ -15,6 +19,9 @@ use Payum\Core\Request\ObtainCreditCard; use Payum\Core\Security\SensitiveValue; use Payum\Core\Tests\GenericActionTest; +use PHPUnit\Framework\MockObject\MockObject; +use ReflectionClass; +use stdClass; class CaptureActionTest extends GenericActionTest { @@ -24,42 +31,42 @@ class CaptureActionTest extends GenericActionTest public function testShouldImplementActionInterface() { - $rc = new \ReflectionClass(CaptureAction::class); + $rc = new ReflectionClass(CaptureAction::class); $this->assertTrue($rc->implementsInterface(ActionInterface::class)); } public function testShouldImplementGatewayAwareInterface() { - $rc = new \ReflectionClass(CaptureAction::class); + $rc = new ReflectionClass(CaptureAction::class); $this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class)); } public function testShouldImplementApiAwareInterface() { - $rc = new \ReflectionClass(CaptureAction::class); + $rc = new ReflectionClass(CaptureAction::class); $this->assertTrue($rc->implementsInterface(ApiAwareInterface::class)); } public function testThrowIfUnsupportedApiGiven() { - $this->expectException(\Payum\Core\Exception\UnsupportedApiException::class); + $this->expectException(UnsupportedApiException::class); $action = new CaptureAction(); - $action->setApi(new \stdClass()); + $action->setApi(new stdClass()); } public function testThrowIfCreditCardNotSetExplicitlyAndObtainRequestNotSupportedOnCapture() { - $this->expectException(\Payum\Core\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('Credit card details has to be set explicitly or there has to be an action that supports ObtainCreditCard request.'); $gatewayMock = $this->createGatewayMock(); $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\ObtainCreditCard::class)) + ->with($this->isInstanceOf(ObtainCreditCard::class)) ->willThrowException(new RequestNotSupportedException()) ; @@ -155,11 +162,11 @@ public function testShouldCaptureWithObtainedCreditCard() $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\ObtainCreditCard::class)) + ->with($this->isInstanceOf(ObtainCreditCard::class)) ->willReturnCallback(function (ObtainCreditCard $request) { $card = new CreditCard(); $card->setNumber('1234567812345678'); - $card->setExpireAt(new \DateTime('2014-10-01')); + $card->setExpireAt(new DateTime('2014-10-01')); $card->setHolder('John Doe'); $card->setSecurityCode('123'); @@ -211,7 +218,7 @@ public function testShouldCaptureWithObtainedCreditCardWhenTokenReturned() $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\ObtainCreditCard::class)) + ->with($this->isInstanceOf(ObtainCreditCard::class)) ->willReturnCallback(function (ObtainCreditCard $request) { $card = new CreditCard(); $card->setToken('theCreditCardToken'); @@ -259,8 +266,8 @@ public function testShouldCaptureWithObtainedCreditCardWhenTokenReturned() public function testShouldPassFirstAndCurrentModelsWithObtainCreditCardSubRequest() { - $firstModel = new \stdClass(); - $currentModel = new \ArrayObject([ + $firstModel = new stdClass(); + $currentModel = new ArrayObject([ 'AMOUNT' => 10, 'CLIENTUSERAGENT' => 'anAgent', 'CLIENTIP' => '127.0.0.1', @@ -280,13 +287,13 @@ public function testShouldPassFirstAndCurrentModelsWithObtainCreditCardSubReques $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\ObtainCreditCard::class)) + ->with($this->isInstanceOf(ObtainCreditCard::class)) ->willReturnCallback(function (ObtainCreditCard $request) use ($firstModel, $currentModel) { $this->assertSame($firstModel, $request->getFirstModel()); $this->assertSame($currentModel, $request->getModel()); $card = new CreditCard(); - $card->setExpireAt(new \DateTime('2014-10-01')); + $card->setExpireAt(new DateTime('2014-10-01')); $request->set($card); }) @@ -314,7 +321,7 @@ public function testShouldThrowHttpResponseIfExecCode3DSecureRequired() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|Api + * @return MockObject|Api */ protected function createApiMock() { @@ -322,7 +329,7 @@ protected function createApiMock() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|GatewayInterface + * @return MockObject|GatewayInterface */ protected function createGatewayMock() { diff --git a/Tests/Action/CaptureOffsiteActionTest.php b/Tests/Action/CaptureOffsiteActionTest.php index d2025dc..b9cbb9e 100644 --- a/Tests/Action/CaptureOffsiteActionTest.php +++ b/Tests/Action/CaptureOffsiteActionTest.php @@ -6,11 +6,16 @@ use Payum\Be2Bill\Api; use Payum\Core\Action\ActionInterface; use Payum\Core\ApiAwareInterface; +use Payum\Core\Exception\UnsupportedApiException; use Payum\Core\GatewayAwareInterface; use Payum\Core\GatewayInterface; +use Payum\Core\Reply\HttpPostRedirect; use Payum\Core\Request\Capture; use Payum\Core\Request\GetHttpRequest; use Payum\Core\Tests\GenericActionTest; +use PHPUnit\Framework\MockObject\MockObject; +use ReflectionClass; +use stdClass; class CaptureOffsiteActionTest extends GenericActionTest { @@ -20,36 +25,36 @@ class CaptureOffsiteActionTest extends GenericActionTest public function testShouldImplementActionInterface() { - $rc = new \ReflectionClass(CaptureOffsiteAction::class); + $rc = new ReflectionClass(CaptureOffsiteAction::class); $this->assertTrue($rc->implementsInterface(ActionInterface::class)); } public function testShouldImplementGatewayAwareInterface() { - $rc = new \ReflectionClass(CaptureOffsiteAction::class); + $rc = new ReflectionClass(CaptureOffsiteAction::class); $this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class)); } public function testShouldImplementApiAwareInterface() { - $rc = new \ReflectionClass(CaptureOffsiteAction::class); + $rc = new ReflectionClass(CaptureOffsiteAction::class); $this->assertTrue($rc->implementsInterface(ApiAwareInterface::class)); } public function testThrowIfUnsupportedApiGiven() { - $this->expectException(\Payum\Core\Exception\UnsupportedApiException::class); + $this->expectException(UnsupportedApiException::class); $action = new CaptureOffsiteAction(); - $action->setApi(new \stdClass()); + $action->setApi(new stdClass()); } public function testShouldRedirectToBe2billSiteIfExecCodeNotPresentInQuery() { - $this->expectException(\Payum\Core\Reply\HttpPostRedirect::class); + $this->expectException(HttpPostRedirect::class); $model = [ 'AMOUNT' => 1000, 'CLIENTIDENT' => 'payerId', @@ -74,7 +79,7 @@ public function testShouldRedirectToBe2billSiteIfExecCodeNotPresentInQuery() $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\GetHttpRequest::class)) + ->with($this->isInstanceOf(GetHttpRequest::class)) ; $action = new CaptureOffsiteAction(); @@ -105,7 +110,7 @@ public function testShouldUpdateModelWhenComeBackFromBe2billSite() $gatewayMock ->expects($this->once()) ->method('execute') - ->with($this->isInstanceOf(\Payum\Core\Request\GetHttpRequest::class)) + ->with($this->isInstanceOf(GetHttpRequest::class)) ->willReturnCallback(function (GetHttpRequest $request) { $request->query['EXECCODE'] = 1; $request->query['FOO'] = 'fooVal'; @@ -132,7 +137,7 @@ public function testShouldUpdateModelWhenComeBackFromBe2billSite() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|Api + * @return MockObject|Api */ protected function createApiMock() { @@ -140,7 +145,7 @@ protected function createApiMock() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|GatewayInterface + * @return MockObject|GatewayInterface */ protected function createGatewayMock() { diff --git a/Tests/Action/ConvertPaymentActionTest.php b/Tests/Action/ConvertPaymentActionTest.php index d8caad8..af4b536 100644 --- a/Tests/Action/ConvertPaymentActionTest.php +++ b/Tests/Action/ConvertPaymentActionTest.php @@ -2,11 +2,15 @@ namespace Payum\Be2Bill\Tests\Action; +use Iterator; use Payum\Be2Bill\Action\ConvertPaymentAction; use Payum\Core\Model\Payment; use Payum\Core\Model\PaymentInterface; use Payum\Core\Request\Convert; +use Payum\Core\Request\Generic; +use Payum\Core\Security\TokenInterface; use Payum\Core\Tests\GenericActionTest; +use stdClass; class ConvertPaymentActionTest extends GenericActionTest { @@ -14,20 +18,20 @@ class ConvertPaymentActionTest extends GenericActionTest protected $requestClass = Convert::class; - public function provideSupportedRequests(): \Iterator + public function provideSupportedRequests(): Iterator { yield [new $this->requestClass(new Payment(), 'array')]; yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'array')]; - yield [new $this->requestClass(new Payment(), 'array', $this->createMock(\Payum\Core\Security\TokenInterface::class))]; + yield [new $this->requestClass(new Payment(), 'array', $this->createMock(TokenInterface::class))]; } - public function provideNotSupportedRequests(): \Iterator + public function provideNotSupportedRequests(): Iterator { yield ['foo']; yield [['foo']]; - yield [new \stdClass()]; - yield [$this->getMockForAbstractClass(\Payum\Core\Request\Generic::class, [[]])]; - yield [new $this->requestClass(new \stdClass(), 'array')]; + yield [new stdClass()]; + yield [$this->getMockForAbstractClass(Generic::class, [[]])]; + yield [new $this->requestClass(new stdClass(), 'array')]; yield [new $this->requestClass(new Payment(), 'foobar')]; yield [new $this->requestClass($this->createMock(PaymentInterface::class), 'foobar')]; } diff --git a/Tests/Action/NotifyActionTest.php b/Tests/Action/NotifyActionTest.php index 6fe0376..566a7e7 100644 --- a/Tests/Action/NotifyActionTest.php +++ b/Tests/Action/NotifyActionTest.php @@ -2,15 +2,20 @@ namespace Payum\Be2Bill\Tests\Action; +use ArrayObject; use Payum\Be2Bill\Action\NotifyAction; use Payum\Be2Bill\Api; use Payum\Core\ApiAwareInterface; +use Payum\Core\Exception\UnsupportedApiException; use Payum\Core\GatewayAwareInterface; use Payum\Core\GatewayInterface; use Payum\Core\Reply\HttpResponse; use Payum\Core\Request\GetHttpRequest; use Payum\Core\Request\Notify; use Payum\Core\Tests\GenericActionTest; +use PHPUnit\Framework\MockObject\MockObject; +use ReflectionClass; +use stdClass; class NotifyActionTest extends GenericActionTest { @@ -20,24 +25,24 @@ class NotifyActionTest extends GenericActionTest public function testShouldImplementGatewayAwareInterface() { - $rc = new \ReflectionClass(NotifyAction::class); + $rc = new ReflectionClass(NotifyAction::class); $this->assertTrue($rc->implementsInterface(GatewayAwareInterface::class)); } public function testShouldImplementApiAwareInterface() { - $rc = new \ReflectionClass(NotifyAction::class); + $rc = new ReflectionClass(NotifyAction::class); $this->assertTrue($rc->implementsInterface(ApiAwareInterface::class)); } public function testThrowIfUnsupportedApiGiven() { - $this->expectException(\Payum\Core\Exception\UnsupportedApiException::class); + $this->expectException(UnsupportedApiException::class); $action = new NotifyAction(); - $action->setApi(new \stdClass()); + $action->setApi(new stdClass()); } public function testThrowIfQueryHashDoesNotMatchExpected() @@ -141,7 +146,7 @@ public function testShouldUpdateModelIfNotificationValid() $action->setGateway($gatewayMock); $action->setApi($apiMock); - $model = new \ArrayObject([ + $model = new ArrayObject([ 'AMOUNT' => 1.0, 'FOO' => 'FOOOLD', ]); @@ -165,7 +170,7 @@ public function testShouldUpdateModelIfNotificationValid() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|Api + * @return MockObject|Api */ protected function createApiMock() { @@ -173,7 +178,7 @@ protected function createApiMock() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|GatewayInterface + * @return MockObject|GatewayInterface */ protected function createGatewayMock() { diff --git a/Tests/ApiTest.php b/Tests/ApiTest.php index 6d8252d..079eaf5 100644 --- a/Tests/ApiTest.php +++ b/Tests/ApiTest.php @@ -2,23 +2,26 @@ namespace Payum\Be2Bill\Tests; +use Http\Message\MessageFactory; use Http\Message\MessageFactory\GuzzleMessageFactory; use Payum\Be2Bill\Api; +use Payum\Core\Exception\LogicException; use Payum\Core\HttpClientInterface; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class ApiTest extends TestCase { public function testThrowIfRequiredOptionsNotSetInConstructor() { - $this->expectException(\Payum\Core\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The identifier, password fields are required.'); new Api([], $this->createHttpClientMock(), $this->createHttpMessageFactory()); } public function testThrowIfSandboxOptionsNotBooleanInConstructor() { - $this->expectException(\Payum\Core\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The boolean sandbox option must be set.'); new Api([ 'identifier' => 'anId', @@ -155,15 +158,15 @@ public function testShouldReturnTrueIfHashesMatched() } /** - * @return \PHPUnit\Framework\MockObject\MockObject|HttpClientInterface + * @return MockObject|HttpClientInterface */ protected function createHttpClientMock() { - return $this->createMock(\Payum\Core\HttpClientInterface::class); + return $this->createMock(HttpClientInterface::class); } /** - * @return \Http\Message\MessageFactory + * @return MessageFactory */ protected function createHttpMessageFactory() { diff --git a/Tests/Be2BillDirectGatewayFactoryTest.php b/Tests/Be2BillDirectGatewayFactoryTest.php index 55d73e7..d149fc0 100644 --- a/Tests/Be2BillDirectGatewayFactoryTest.php +++ b/Tests/Be2BillDirectGatewayFactoryTest.php @@ -3,6 +3,7 @@ namespace Payum\Be2Bill\Tests; use Payum\Be2Bill\Be2BillDirectGatewayFactory; +use Payum\Core\Exception\LogicException; use Payum\Core\Tests\AbstractGatewayFactoryTest; @@ -59,7 +60,7 @@ public function testShouldConfigContainFactoryNameAndTitle() public function testShouldThrowIfRequiredOptionsNotPassed() { - $this->expectException(\Payum\Core\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The identifier, password fields are required.'); $factory = new Be2BillDirectGatewayFactory(); diff --git a/Tests/Be2BillOffsiteGatewayFactoryTest.php b/Tests/Be2BillOffsiteGatewayFactoryTest.php index 139fd89..a6bd261 100644 --- a/Tests/Be2BillOffsiteGatewayFactoryTest.php +++ b/Tests/Be2BillOffsiteGatewayFactoryTest.php @@ -3,6 +3,7 @@ namespace Payum\Be2Bill\Tests; use Payum\Be2Bill\Be2BillOffsiteGatewayFactory; +use Payum\Core\Exception\LogicException; use Payum\Core\Tests\AbstractGatewayFactoryTest; class Be2BillOffsiteGatewayFactoryTest extends AbstractGatewayFactoryTest @@ -58,7 +59,7 @@ public function testShouldConfigContainFactoryNameAndTitle() public function testShouldThrowIfRequiredOptionsNotPassed() { - $this->expectException(\Payum\Core\Exception\LogicException::class); + $this->expectException(LogicException::class); $this->expectExceptionMessage('The identifier, password fields are required.'); $factory = new Be2BillOffsiteGatewayFactory(); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index cb547ad..af7c74a 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -17,7 +17,7 @@ exit(1); } -$rc = new \ReflectionClass(GatewayInterface::class); +$rc = new ReflectionClass(GatewayInterface::class); $coreDir = dirname($rc->getFileName()) . '/Tests'; $loader->add('Payum\Be2bill\Tests', __DIR__);