forked from Payum/PayumBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
RefundControllerTest.php
64 lines (51 loc) · 1.89 KB
/
RefundControllerTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Payum\Bundle\PayumBundle\Tests\Controller;
use Payum\Bundle\PayumBundle\Controller\RefundController;
use Payum\Core\GatewayInterface;
use Payum\Core\Request\Refund;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
class RefundControllerTest extends AbstractControllerTest
{
/**
* @test
*/
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(RefundController::class);
$this->assertTrue($rc->isSubclassOf(AbstractController::class));
}
/**
* @test
*/
public function shouldExecuteRefundRequest(): void
{
$controller = new RefundController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
$response = $controller->doAction($this->request);
$this->assertInstanceOf(RedirectResponse::class, $response);
$this->assertEquals(self::AFTER_URL, $response->getTargetUrl());
}
/**
* @test
*/
public function shouldExecuteRefundRequestWithoutAfterUrl(): void
{
$this->token->setAfterUrl(null);
$controller = new RefundController();
$controller->setContainer(new ServiceLocator(['payum' => function () { return $this->payum; }]));
$response = $controller->doAction($this->request);
$this->assertInstanceOf(Response::class, $response);
$this->assertEquals(204, $response->getStatusCode());
}
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
->expects($this->any())
->method('execute')
->with($this->isInstanceOf(Refund::class));
}
}