Skip to content

Commit

Permalink
tests - use assetsSame instead of assertEquals
Browse files Browse the repository at this point in the history
  • Loading branch information
mustapayev committed Oct 2, 2024
1 parent c765b17 commit 9a3f831
Show file tree
Hide file tree
Showing 18 changed files with 244 additions and 284 deletions.
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/EstPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function testCreate3DHash(): void
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand All @@ -73,7 +73,7 @@ public function testCreate3DHashFor3DPay(): void
$expected = 'S7UxUAohxaxzl35WxHyDfuQx0sg=';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/EstV3PosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ public function testCreate3DHashFor3DPay(): void
];

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function testCreate3DHashFor3DSecure(): void
Expand All @@ -95,7 +95,7 @@ public function testCreate3DHashFor3DSecure(): void

$expected = '4aUsG5hqlIFLc9s8PKc5rWb2OLhmxDDewNgKa2XrwoYCIxlyVq8Fjl4IVaZzoqL983CfTseicmnTA0PjZr74xg==';
$actual = $this->crypt->create3DHash($this->account, $inputs);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function threeDHashCheckDataProvider(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Crypt/GarantiPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public function testCreate3DHash(): void
public function testCreateHash(array $requestData, string $expected): void
{
$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function threeDHashCheckDataProvider(): array
Expand Down
2 changes: 1 addition & 1 deletion tests/Unit/Crypt/PosNetV1PosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public function testHashFromParamsWhenNotFound(): void
public function testCreateHash(array $requestData, string $expected): void
{
$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}


Expand Down
4 changes: 2 additions & 2 deletions tests/Unit/Crypt/ToslaPosCryptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function testCreate3DHash(): void
$expected = 'BwZ05tt0aNgIgtrrqmlTwSIaeetpQyyGLH6xTsQbHae7ANCIVKmLHPxYWk5XP3Li5fr4La1bZS9/43OihP0dig==';

$actual = $this->crypt->create3DHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function testCreateHash(): void
Expand All @@ -57,7 +57,7 @@ public function testCreateHash(): void
$expected = 'BwZ05tt0aNgIgtrrqmlTwSIaeetpQyyGLH6xTsQbHae7ANCIVKmLHPxYWk5XP3Li5fr4La1bZS9/43OihP0dig==';

$actual = $this->crypt->createHash($this->account, $requestData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
182 changes: 67 additions & 115 deletions tests/Unit/DataMapper/RequestDataMapper/EstPosRequestDataMapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public function testCreateNonSecurePostAuthPaymentRequestData(array $order, arra
{
$actual = $this->requestDataMapper->createNonSecurePostAuthPaymentRequestData($this->account, $order);

$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand All @@ -164,34 +164,13 @@ public function testCreateNonSecurePaymentRequestData(array $order, CreditCardIn
}

/**
* @return void
*/
public function testCreateCancelRequestData(): void
{
$order = [
'id' => '2020110828BC',
];

$actual = $this->requestDataMapper->createCancelRequestData($this->account, $order);

$expectedData = $this->getSampleCancelXMLData($this->account, $order);
$this->assertEquals($expectedData, $actual);
}

/**
* @return void
* @dataProvider createCancelRequestDataProvider
*/
public function testCreateCancelRecurringOrderRequestData(): void
public function testCreateCancelRequestData(array $order, array $expected): void
{
$order = [
'id' => '2020110828BC',
'recurringOrderInstallmentNumber' => '2',
];

$actual = $this->requestDataMapper->createCancelRequestData($this->account, $order);

$expectedData = $this->getSampleRecurringOrderCancelXMLData($this->account, $order);
$this->assertEquals($expectedData, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand All @@ -200,7 +179,7 @@ public function testCreateCancelRecurringOrderRequestData(): void
public function testCreateOrderHistoryRequestData(array $order, array $expected): void
{
$actual = $this->requestDataMapper->createOrderHistoryRequestData($this->account, $order);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public function testCreateHistoryRequestData(): void
Expand All @@ -215,7 +194,7 @@ public function testCreateHistoryRequestData(): void
public function testCreate3DPaymentRequestData(AbstractPosAccount $posAccount, array $order, string $txType, array $responseData, array $expected): void
{
$actual = $this->requestDataMapper->create3DPaymentRequestData($posAccount, $order, $txType, $responseData);
$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down Expand Up @@ -255,37 +234,17 @@ public function testGet3DFormData(
$isWithCard ? $this->card : null
);

$this->assertEquals($expected, $actual);
}

/**
* @return void
*/
public function testCreateStatusRequestData(): void
{
$order = [
'id' => '2020110828BC',
];

$actualData = $this->requestDataMapper->createStatusRequestData($this->account, $order);

$expectedData = $this->getSampleStatusRequestData($this->account, $order);
$this->assertEquals($expectedData, $actualData);
$this->assertSame($expected, $actual);
}

/**
* @return void
* @dataProvider statusRequestDataProvider
*/
public function testCreateRecurringStatusRequestData(): void
public function testCreateStatusRequestData(array $order, array $expected): void
{
$order = [
'recurringId' => '2020110828BC',
];

$actualData = $this->requestDataMapper->createStatusRequestData($this->account, $order);

$expectedData = $this->getSampleRecurringStatusRequestData($this->account, $order);
$this->assertEquals($expectedData, $actualData);
$this->assertSame($expected, $actualData);
}

/**
Expand Down Expand Up @@ -424,8 +383,8 @@ public static function threeDFormDataProvider(): array
'lang' => 'tr',
'currency' => '949',
'taksit' => '',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
'islemtipi' => 'Auth',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
],
],
],
Expand All @@ -450,11 +409,11 @@ public static function threeDFormDataProvider(): array
'currency' => '949',
'taksit' => '',
'islemtipi' => 'Auth',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
'pan' => '5555444433332222',
'Ecom_Payment_Card_ExpDate_Month' => '01',
'Ecom_Payment_Card_ExpDate_Year' => '22',
'cv2' => '123',
'hash' => 'TN+2/D8lijFd+5zAUar6SH6EiRY=',
],
],
],
Expand Down Expand Up @@ -597,39 +556,36 @@ public static function refundRequestDataProvider(): array
];
}

/**
* @param AbstractPosAccount $posAccount
* @param array $order
*
* @return array
*/
private function getSampleCancelXMLData(AbstractPosAccount $posAccount, array $order): array
public static function createCancelRequestDataProvider(): array
{
return [
'Name' => $posAccount->getUsername(),
'Password' => $posAccount->getPassword(),
'ClientId' => $posAccount->getClientId(),
'OrderId' => $order['id'],
'Type' => 'Void',
];
}

/**
* @param AbstractPosAccount $posAccount
* @param array $order
*
* @return array
*/
private function getSampleRecurringOrderCancelXMLData(AbstractPosAccount $posAccount, array $order): array
{
return [
'Name' => $posAccount->getUsername(),
'Password' => $posAccount->getPassword(),
'ClientId' => $posAccount->getClientId(),
'Extra' => [
'RECORDTYPE' => 'Order',
'RECURRINGOPERATION' => 'Cancel',
'RECORDID' => $order['id'].'-'.$order['recurringOrderInstallmentNumber'],
[
'order' => [
'id' => '2020110828BC',
],
'expected' => [
'Name' => 'ISBANKAPI',
'Password' => 'ISBANK07',
'ClientId' => '700655000200',
'OrderId' => '2020110828BC',
'Type' => 'Void',
],
],
[
'order' => [
'id' => '2020110828BC',
'recurringOrderInstallmentNumber' => '2',
],
'expected' => [
'Name' => 'ISBANKAPI',
'Password' => 'ISBANK07',
'ClientId' => '700655000200',
'Extra' => [
'RECORDTYPE' => 'Order',
'RECURRINGOPERATION' => 'Cancel',
'RECORDID' => '2020110828BC-2',
],
],
],
];
}
Expand Down Expand Up @@ -707,40 +663,36 @@ public static function nonSecurePaymentRequestDataDataProvider(): array
];
}

/**
* @param AbstractPosAccount $posAccount
* @param array $order
*
* @return array
*/
private function getSampleStatusRequestData(AbstractPosAccount $posAccount, array $order): array
public static function statusRequestDataProvider(): array
{
return [
'Name' => $posAccount->getUsername(),
'Password' => $posAccount->getPassword(),
'ClientId' => $posAccount->getClientId(),
'OrderId' => $order['id'],
'Extra' => [
'ORDERSTATUS' => 'QUERY',
[
'order' => [
'id' => '2020110828BC',
],
'expected' => [
'Name' => 'ISBANKAPI',
'Password' => 'ISBANK07',
'ClientId' => '700655000200',
'Extra' => [
'ORDERSTATUS' => 'QUERY',
],
'OrderId' => '2020110828BC',
],
],
];
}

/**
* @param AbstractPosAccount $posAccount
* @param array $order
*
* @return array
*/
private function getSampleRecurringStatusRequestData(AbstractPosAccount $posAccount, array $order): array
{
return [
'Name' => $posAccount->getUsername(),
'Password' => $posAccount->getPassword(),
'ClientId' => $posAccount->getClientId(),
'Extra' => [
'ORDERSTATUS' => 'QUERY',
'RECURRINGID' => $order['recurringId'],
[
'order' => [
'recurringId' => '22303O8EA19252',
],
'expected' => [
'Name' => 'ISBANKAPI',
'Password' => 'ISBANK07',
'ClientId' => '700655000200',
'Extra' => [
'ORDERSTATUS' => 'QUERY',
'RECURRINGID' => '22303O8EA19252',
],
],
],
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public function testGet3DFormData(
$isWithCard ? $this->card : null
);

$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

public static function threeDFormDataProvider(): array
Expand Down Expand Up @@ -155,13 +155,13 @@ public static function threeDFormDataProvider(): array
'lang' => 'tr',
'currency' => '949',
'taksit' => '',
'TranType' => 'Auth',
'hashAlgorithm' => 'ver3',
'hash' => '3fvBzh0HT3UiKUTXis0Ke2NG3mAp9eBOwx26bstv+l6L946GrOF2JklXfqTNc6VBeqUSkuLxo4ErtwCWuPCzYw==',
'pan' => '5555444433332222',
'Ecom_Payment_Card_ExpDate_Month' => '01',
'Ecom_Payment_Card_ExpDate_Year' => '22',
'cv2' => '123',
'TranType' => 'Auth',
'hashAlgorithm' => 'ver3',
'hash' => '3fvBzh0HT3UiKUTXis0Ke2NG3mAp9eBOwx26bstv+l6L946GrOF2JklXfqTNc6VBeqUSkuLxo4ErtwCWuPCzYw==',
],
],
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ public function testCreate3DPaymentRequestData(GarantiPosAccount $garantiPosAcco

$actual = $this->requestDataMapper->create3DPaymentRequestData($this->account, $order, '', $responseData);

$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ public function testCreateCancelRequestData(array $order, array $expected): void
\ksort($actual);
\ksort($expected);

$this->assertEquals($expected, $actual);
$this->assertSame($expected, $actual);
}

/**
Expand Down
Loading

0 comments on commit 9a3f831

Please sign in to comment.