|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/* |
|
4
|
|
|
* |
|
5
|
|
|
* (c) Yaroslav Honcharuk <[email protected]> |
|
6
|
|
|
* |
|
7
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
8
|
|
|
* file that was distributed with this source code. |
|
9
|
|
|
*/ |
|
10
|
|
|
|
|
11
|
|
|
namespace Yarhon\RouteGuardBundle\Tests\Controller\ArgumentResolver; |
|
12
|
|
|
|
|
13
|
|
|
use PHPUnit\Framework\TestCase; |
|
14
|
|
|
use Symfony\Component\HttpFoundation\Request; |
|
15
|
|
|
use Symfony\Component\HttpFoundation\ParameterBag; |
|
16
|
|
|
use Yarhon\RouteGuardBundle\Controller\ArgumentResolver\ArgumentResolverContext; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* @author Yaroslav Honcharuk <[email protected]> |
|
20
|
|
|
*/ |
|
21
|
|
|
class ArgumentResolverContextTest extends TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
public function testGetRequest() |
|
24
|
|
|
{ |
|
25
|
|
|
$attributes = $this->createMock(ParameterBag::class); |
|
26
|
|
|
$controllerName = 'a::b'; |
|
27
|
|
|
$request = $this->createMock(Request::class); |
|
28
|
|
|
|
|
29
|
|
|
$context = new ArgumentResolverContext($attributes, $controllerName, $request); |
|
30
|
|
|
|
|
31
|
|
|
$this->assertSame($request, $context->getRequest()); |
|
32
|
|
|
|
|
33
|
|
|
$context = new ArgumentResolverContext($attributes, $controllerName); |
|
34
|
|
|
|
|
35
|
|
|
$this->assertNull($context->getRequest()); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
public function testGetAttributes() |
|
39
|
|
|
{ |
|
40
|
|
|
$attributes = $this->createMock(ParameterBag::class); |
|
41
|
|
|
$controllerName = 'a::b'; |
|
42
|
|
|
|
|
43
|
|
|
$context = new ArgumentResolverContext($attributes, $controllerName); |
|
44
|
|
|
|
|
45
|
|
|
$this->assertSame($attributes, $context->getAttributes()); |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
public function testGetControllerName() |
|
49
|
|
|
{ |
|
50
|
|
|
$attributes = $this->createMock(ParameterBag::class); |
|
51
|
|
|
$controllerName = 'a::b'; |
|
52
|
|
|
|
|
53
|
|
|
$context = new ArgumentResolverContext($attributes, $controllerName); |
|
54
|
|
|
|
|
55
|
|
|
$this->assertSame($controllerName, $context->getControllerName()); |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|