Skip to content

Commit

Permalink
test - remove usages of CreditCardFactory::createForGateway from requ…
Browse files Browse the repository at this point in the history
…est data mappers for simplicity
  • Loading branch information
nuryagdym committed May 22, 2024
1 parent 42b2892 commit 64d8b12
Show file tree
Hide file tree
Showing 10 changed files with 11 additions and 56 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\EstPos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -44,8 +43,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createEstPosAccount(
'akbank',
'700655000200',
Expand All @@ -67,10 +64,9 @@ protected function setUp(): void
];
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$this->crypt = $this->createMock(CryptInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->requestDataMapper = new EstPosRequestDataMapper($this->dispatcher, $this->crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Mews\Pos\Event\Before3DFormHashCalculatedEvent;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\EstV3Pos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -40,8 +39,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createEstPosAccount(
'payten_v3_hash',
'190100000',
Expand All @@ -52,11 +49,10 @@ protected function setUp(): void
);

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->crypt = $this->createMock(CryptInterface::class);
$this->requestDataMapper = new EstV3PosRequestDataMapper($this->dispatcher, $this->crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\CryptFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\GarantiPos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -35,17 +34,13 @@ class GarantiPosRequestDataMapperTest extends TestCase

private array $order;

private $config;

/** @var EventDispatcherInterface & MockObject */
private EventDispatcherInterface $dispatcher;

protected function setUp(): void
{
parent::setUp();

$this->config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createGarantiPosAccount(
'garanti',
'7000679',
Expand All @@ -70,13 +65,12 @@ protected function setUp(): void
];

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $this->config, $this->dispatcher);

$crypt = CryptFactory::createGatewayCrypt(GarantiPos::class, new NullLogger());
$this->requestDataMapper = new GarantiPosRequestDataMapper($this->dispatcher, $crypt);
$this->requestDataMapper->setTestMode(true);

$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet');
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet');
}

/**
Expand Down Expand Up @@ -212,7 +206,7 @@ public function testCreate3DPaymentRequestData(GarantiPosAccount $garantiPosAcco
public function testGet3DFormData(): void
{
$account = $this->account;
$gatewayURL = $this->config['banks'][$this->account->getBank()]['gateway_endpoints']['gateway_3d'];
$gatewayURL = 'https://sanalposprovtest.garantibbva.com.tr/servlet/gt3dengine';
$inputs = [
'secure3dsecuritylevel' => '3D',
'mode' => 'TEST',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\InterPos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -43,8 +42,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$userCode = 'InterTestApi';
$userPass = '3';
$shopCode = '3123';
Expand All @@ -70,12 +67,11 @@ protected function setUp(): void
];

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->crypt = $this->createMock(CryptInterface::class);
$this->requestDataMapper = new InterPosRequestDataMapper($this->dispatcher, $this->crypt);

$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '21', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$this->card = CreditCardFactory::create('5555444433332222', '21', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,12 @@
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\CryptFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\PayFlexCPV4Pos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\EventDispatcher\EventDispatcherInterface;
use Psr\Log\NullLogger;
use Symfony\Component\EventDispatcher\EventDispatcher;

/**
* @covers \Mews\Pos\DataMapper\RequestDataMapper\PayFlexCPV4PosRequestDataMapper
Expand Down Expand Up @@ -183,10 +181,7 @@ public static function registerDataProvider(): iterable
'ip' => '127.0.0.1',
];

$pos = PosFactory::createPosGateway($account, $config, new EventDispatcher());
$pos->setTestMode(true);

$card = CreditCardFactory::createForGateway($pos, '5555444433332222', '2021', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$card = CreditCardFactory::create('5555444433332222', '2021', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);

yield 'with_card_1' => [
'account' => $account,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand Down Expand Up @@ -43,8 +42,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createPayFlexAccount(
'vakifbank',
'000000000111111',
Expand All @@ -65,11 +62,10 @@ protected function setUp(): void
];

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->crypt = $this->createMock(CryptInterface::class);
$this->requestDataMapper = new PayFlexV4PosRequestDataMapper($this->dispatcher, $this->crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '2021', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$this->card = CreditCardFactory::create('5555444433332222', '2021', '12', '122', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\PayForPos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -37,17 +36,13 @@ class PayForPosRequestDataMapperTest extends TestCase

private array $order;

private array $config;

/** @var EventDispatcherInterface & MockObject */
private EventDispatcherInterface $dispatcher;

protected function setUp(): void
{
parent::setUp();

$this->config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createPayForAccount(
'qnbfinansbank-payfor',
'085300000009704',
Expand All @@ -69,10 +64,9 @@ protected function setUp(): void

$this->crypt = $this->createMock(CryptInterface::class);
$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $this->config, $this->dispatcher);

$this->requestDataMapper = new PayForPosRequestDataMapper($this->dispatcher, $this->crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet');
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\CryptFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\PosNet;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand Down Expand Up @@ -41,8 +40,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createPosNetAccount(
'yapikredi',
'6706598320',
Expand All @@ -63,10 +60,9 @@ protected function setUp(): void
];

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);
$crypt = CryptFactory::createGatewayCrypt(PosNet::class, new NullLogger());
$this->requestDataMapper = new PosNetRequestDataMapper($this->dispatcher, $crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet');
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet');
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\CryptFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\Gateways\PosNetV1Pos;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
Expand All @@ -40,8 +39,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createPosNetAccount(
'albaraka',
'6700950031',
Expand All @@ -52,9 +49,8 @@ protected function setUp(): void
);

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->card = CreditCardFactory::createForGateway($pos, '5400619360964581', '20', '01', '056', 'ahmet');
$this->card = CreditCardFactory::create('5400619360964581', '20', '01', '056', 'ahmet');

$crypt = CryptFactory::createGatewayCrypt(PosNetV1Pos::class, new NullLogger());
$this->requestDataMapper = new PosNetV1PosRequestDataMapper($this->dispatcher, $crypt);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use Mews\Pos\Exceptions\UnsupportedTransactionTypeException;
use Mews\Pos\Factory\AccountFactory;
use Mews\Pos\Factory\CreditCardFactory;
use Mews\Pos\Factory\PosFactory;
use Mews\Pos\PosInterface;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
Expand All @@ -39,8 +38,6 @@ protected function setUp(): void
{
parent::setUp();

$config = require __DIR__.'/../../../../config/pos_test.php';

$this->account = AccountFactory::createToslaPosAccount(
'tosla',
'1000000494',
Expand All @@ -49,11 +46,10 @@ protected function setUp(): void
);

$this->dispatcher = $this->createMock(EventDispatcherInterface::class);
$pos = PosFactory::createPosGateway($this->account, $config, $this->dispatcher);

$this->crypt = $this->createMock(CryptInterface::class);
$this->requestDataMapper = new ToslaPosRequestDataMapper($this->dispatcher, $this->crypt);
$this->card = CreditCardFactory::createForGateway($pos, '5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
$this->card = CreditCardFactory::create('5555444433332222', '22', '01', '123', 'ahmet', CreditCardInterface::CARD_TYPE_VISA);
}

/**
Expand Down

0 comments on commit 64d8b12

Please sign in to comment.