|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Pronamic\WordPress\Pay\Gateways\TargetPay; |
|
4
|
|
|
|
|
5
|
|
|
use PHPUnit_Framework_TestCase; |
|
6
|
|
|
|
|
7
|
|
|
/** |
|
8
|
|
|
* Title: TargetPay status string parser test |
|
9
|
|
|
* Description: |
|
10
|
|
|
* Copyright: 2005-2021 Pronamic |
|
11
|
|
|
* Company: Pronamic |
|
12
|
|
|
* |
|
13
|
|
|
* @author Remco Tolsma |
|
14
|
|
|
* @version 2.0.0 |
|
15
|
|
|
* @since 1.0.0 |
|
16
|
|
|
*/ |
|
17
|
|
|
class StatusStringParserTest extends PHPUnit_Framework_TestCase { |
|
18
|
|
|
public function test_parse_status_ok() { |
|
19
|
|
|
$status_string = '000000 OK'; |
|
20
|
|
|
|
|
21
|
|
|
$status = StatusStringParser::parse( $status_string ); |
|
22
|
|
|
|
|
23
|
|
|
$this->assertInstanceOf( 'Pronamic\WordPress\Pay\Gateways\TargetPay\Status', $status ); |
|
24
|
|
|
|
|
25
|
|
|
$this->assertEquals( '000000', $status->code ); |
|
26
|
|
|
$this->assertEquals( 'OK', $status->description ); |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
public function test_parse_status_ok_cinfo() { |
|
30
|
|
|
$status_string = '00000 OK|123456789|Pronamic|Drachten'; |
|
31
|
|
|
|
|
32
|
|
|
$status = StatusStringParser::parse( $status_string ); |
|
33
|
|
|
|
|
34
|
|
|
$this->assertInstanceOf( 'Pronamic\WordPress\Pay\Gateways\TargetPay\Status', $status ); |
|
35
|
|
|
|
|
36
|
|
|
$this->assertEquals( '00000', $status->code ); |
|
37
|
|
|
$this->assertEquals( 'OK', $status->description ); |
|
38
|
|
|
$this->assertEquals( '123456789', $status->account_number ); |
|
39
|
|
|
$this->assertEquals( 'Pronamic', $status->account_name ); |
|
40
|
|
|
$this->assertEquals( 'Drachten', $status->account_city ); |
|
41
|
|
|
} |
|
42
|
|
|
|
|
43
|
|
|
public function test_parse_status_tp0010() { |
|
44
|
|
|
$status_string = 'TP0010 Transaction has not been completed, try again later'; |
|
45
|
|
|
|
|
46
|
|
|
$status = StatusStringParser::parse( $status_string ); |
|
47
|
|
|
|
|
48
|
|
|
$this->assertInstanceOf( 'Pronamic\WordPress\Pay\Gateways\TargetPay\Status', $status ); |
|
49
|
|
|
|
|
50
|
|
|
$this->assertEquals( 'TP0010', $status->code ); |
|
51
|
|
|
$this->assertEquals( 'Transaction has not been completed, try again later', $status->description ); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
|