1 | <?php |
||
22 | abstract class TestCase extends BaseTestCase |
||
23 | { |
||
24 | /** |
||
25 | * @var \yiiviet\payment\BasePaymentGateway |
||
26 | */ |
||
27 | public $gateway; |
||
28 | |||
29 | public function setUp() |
||
30 | { |
||
31 | parent::setUp(); |
||
32 | |||
33 | $this->mockApplication(); |
||
34 | $this->gateway = Yii::$app->get('paymentGateways')->getGateway(static::gatewayId()); |
||
35 | } |
||
36 | |||
37 | public function tearDown() |
||
38 | { |
||
39 | parent::tearDown(); |
||
40 | |||
41 | $this->destroyApplication(); |
||
42 | $this->gateway = null; |
||
43 | } |
||
44 | |||
45 | abstract public static function gatewayId(): string; |
||
46 | |||
47 | |||
48 | public function testEnsureInstance() |
||
53 | |||
54 | /** |
||
55 | * Populates Yii::$app with a new application |
||
56 | * The application will be destroyed on tearDown() automatically. |
||
57 | * @param array $config The application configuration, if needed |
||
58 | * @param string $appClass name of the application class to create |
||
59 | */ |
||
60 | protected function mockApplication($config = [], $appClass = '\yii\web\Application') |
||
90 | |||
91 | /** |
||
92 | * Destroys application in Yii::$app by setting it to null. |
||
93 | */ |
||
94 | protected function destroyApplication() |
||
98 | |||
99 | /** |
||
100 | * @param array $data |
||
101 | * @param null $clientId |
||
102 | * @return \vxm\gatewayclients\ResponseData |
||
103 | */ |
||
104 | protected function purchase(array $data, $clientId = null) |
||
108 | |||
109 | /** |
||
110 | * @param array $data |
||
111 | * @param null $clientId |
||
112 | * @return \vxm\gatewayclients\ResponseData |
||
113 | */ |
||
114 | protected function queryDR(array $data, $clientId = null) |
||
118 | |||
119 | /** |
||
120 | * @param array $data |
||
121 | * @param null $clientId |
||
122 | * @return \vxm\gatewayclients\ResponseData |
||
123 | */ |
||
124 | protected function refund(array $data, $clientId = null) |
||
128 | |||
129 | /** |
||
130 | * @param array $data |
||
131 | * @param null $clientId |
||
132 | * @return \vxm\gatewayclients\ResponseData |
||
133 | */ |
||
134 | protected function queryRefund(array $data, $clientId = null) |
||
138 | |||
139 | /** |
||
140 | * @param \yii\web\Request $request |
||
141 | * @param null $clientId |
||
142 | * @return \yiiviet\payment\VerifiedData |
||
143 | */ |
||
144 | protected function verifyRequestPurchaseSuccess(\yii\web\Request $request = null, $clientId = null) |
||
148 | |||
149 | /** |
||
150 | * @param \yii\web\Request $request |
||
151 | * @param null $clientId |
||
152 | * @return \yiiviet\payment\VerifiedData |
||
153 | */ |
||
154 | protected function verifyRequestIPN(\yii\web\Request $request = null, $clientId = null) |
||
158 | |||
159 | } |
||
160 |