-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ibrahim Gunduz
committed
May 3, 2018
1 parent
97e29fb
commit 578f2b4
Showing
34 changed files
with
1,329 additions
and
134 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
namespace Paranoia\Test\Processor\Gvp; | ||
|
||
use Paranoia\Configuration\AbstractConfiguration; | ||
use Paranoia\Exception\BadResponseException; | ||
use Paranoia\Processor\Gvp\CancelResponseProcessor; | ||
use Paranoia\Response\PaymentResponse; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class CancelResponseProcessorTest extends TestCase | ||
{ | ||
public function test_success_response() | ||
{ | ||
$rawResponse = file_get_contents( | ||
__DIR__ . '/../../samples/response/gvp/cancel_successful.xml' | ||
); | ||
|
||
/** @var AbstractConfiguration $configuration */ | ||
$configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); | ||
$processor = new CancelResponseProcessor($configuration); | ||
$response = $processor->process($rawResponse); | ||
$this->assertInstanceOf(PaymentResponse::class, $response); | ||
$this->assertEquals(true, $response->isSuccess()); | ||
$this->assertEquals('311616674771', $response->getTransactionId()); | ||
$this->assertEquals('489787', $response->getAuthCode()); | ||
$this->assertEquals('1476', $response->getOrderId()); | ||
} | ||
|
||
public function test_failed_response() | ||
{ | ||
$rawResponse = file_get_contents( | ||
__DIR__ . '/../../samples/response/gvp/cancel_failed.xml' | ||
); | ||
|
||
/** @var AbstractConfiguration $configuration */ | ||
$configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); | ||
$processor = new CancelResponseProcessor($configuration); | ||
$response = $processor->process($rawResponse); | ||
$this->assertInstanceOf(PaymentResponse::class, $response); | ||
$this->assertEquals(false, $response->isSuccess()); | ||
$this->assertEquals(null, $response->getTransactionId()); | ||
$this->assertEquals(null, $response->getOrderId()); | ||
$this->assertEquals('0202', $response->getResponseCode()); | ||
$this->assertEquals('Error Message: ›ptal edebileceiniz birden fazla i˛lem var, RRN bilgisi gonderi System Error Message: ErrorId: 0202', $response->getResponseMessage()); | ||
} | ||
|
||
/** | ||
* @dataProvider badResponses | ||
* @param string $rawResponse | ||
*/ | ||
public function test_bad_response($rawResponse) | ||
{ | ||
/** @var AbstractConfiguration $configuration */ | ||
$configuration = $this->getMockBuilder(AbstractConfiguration::class)->getMock(); | ||
$processor = new CancelResponseProcessor($configuration); | ||
|
||
$this->expectException(BadResponseException::class); | ||
$processor->process($rawResponse); | ||
} | ||
|
||
public function badResponses() | ||
{ | ||
return [ | ||
[null], | ||
[''], | ||
['DUMMY'], | ||
[1], | ||
]; | ||
} | ||
|
||
} |
Oops, something went wrong.