forked from Payum/PayumBundle
-
Notifications
You must be signed in to change notification settings - Fork 1
/
AuthorizeControllerTest.php
46 lines (39 loc) · 1.39 KB
/
AuthorizeControllerTest.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
<?php
namespace Payum\Bundle\PayumBundle\Tests\Controller;
use Payum\Bundle\PayumBundle\Controller\AuthorizeController;
use Payum\Core\GatewayInterface;
use Payum\Core\Request\Authorize;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\DependencyInjection\ServiceLocator;
use Symfony\Component\HttpFoundation\RedirectResponse;
class AuthorizeControllerTest extends AbstractControllerTest
{
/**
* @test
*/
public function shouldBeSubClassOfController(): void
{
$rc = new \ReflectionClass(AuthorizeController::class);
$this->assertTrue($rc->isSubclassOf(AbstractController::class));
}
/**
* @test
*/
public function shouldExecuteAuthorizeRequest(): void
{
$controller = new AuthorizeController();
$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());
}
protected function initGatewayMock(): void
{
$this->gatewayMock = $this->createMock(GatewayInterface::class);
$this->gatewayMock
->expects($this->any())
->method('execute')
->with($this->isInstanceOf(Authorize::class))
;
}
}