1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Payments\Mobilpay\Tests\Message; |
4
|
|
|
|
5
|
|
|
use ByTIC\Payments\Mobilpay\Message\CompletePurchaseRequest; |
6
|
|
|
use ByTIC\Payments\Mobilpay\Message\CompletePurchaseResponse; |
7
|
|
|
use ByTIC\Payments\Mobilpay\Tests\AbstractTest; |
8
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Purchases\PurchasableRecord; |
9
|
|
|
use ByTIC\Payments\Tests\Fixtures\Records\Purchases\PurchasableRecordManager; |
10
|
|
|
use Symfony\Component\HttpFoundation\Request; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* Class CompletePurchaseResponseTest |
14
|
|
|
* @package ByTIC\Payments\Mobilpay\Tests\Message |
15
|
|
|
*/ |
16
|
|
|
class CompletePurchaseResponseTest extends AbstractTest |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
public function testResponseForValidTransaction() |
20
|
|
|
{ |
21
|
|
|
$httpRequest = $this->generateRequestFromFixtures( |
22
|
|
|
TEST_FIXTURE_PATH . '/requests/completePurchase/basicParams.php' |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
$model = \Mockery::mock(PurchasableRecord::class)->makePartial(); |
26
|
|
|
$model->shouldReceive('getPaymentGateway')->andReturn(null); |
27
|
|
|
|
28
|
|
|
$modelManager = \Mockery::mock(PurchasableRecordManager::class)->makePartial(); |
29
|
|
|
$modelManager->shouldReceive('findOne')->andReturn($model); |
30
|
|
|
|
31
|
|
|
$request = new CompletePurchaseRequest($this->client, $httpRequest); |
32
|
|
|
$request->setModelManager($modelManager); |
33
|
|
|
|
34
|
|
|
$response = $request->send(); |
35
|
|
|
self::assertInstanceOf(CompletePurchaseResponse::class, $response); |
36
|
|
|
self::assertSame(false, $response->isCancelled()); |
37
|
|
|
self::assertSame(true, $response->isPending()); |
38
|
|
|
self::assertSame('pending', $response->getModelResponseStatus()); |
39
|
|
|
|
40
|
|
|
// $content = $response->getViewContent(); |
41
|
|
|
// |
42
|
|
|
// self::assertStringContainsString('++++', $content); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testHasConfirmHtmlTraitTrait() |
46
|
|
|
{ |
47
|
|
|
$response = $this->getNewResponse(); |
48
|
|
|
|
49
|
|
|
static::assertTrue(method_exists($response, 'getViewFile')); |
50
|
|
|
static::assertTrue(method_exists($response, 'getView')); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
protected function getNewResponse() |
54
|
|
|
{ |
55
|
|
|
$request = new CompletePurchaseRequest($this->client, new Request()); |
56
|
|
|
|
57
|
|
|
return new CompletePurchaseResponse($request, []); |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|