Completed
Push — master ( 055f1b...f72a4b )
by Pavel
52s
created

RoutingTest::testRouting()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 12
ccs 11
cts 11
cp 1
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: batanov.pavel
5
 * Date: 16.05.2016
6
 * Time: 10:38
7
 */
8
9
namespace Bankiru\Api\Rpc\Tests;
10
11
use Bankiru\Api\Rpc\Routing\MethodCollection;
12
use Bankiru\Api\Rpc\Routing\Router;
13
use Bankiru\Api\Rpc\Tests\Fixtures\Kernel;
14
use Bankiru\Api\Rpc\Tests\Fixtures\Rpc\TestController;
15
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
16
use Symfony\Component\Routing\RequestContext;
17
18
class RoutingTest extends WebTestCase
19
{
20 1
    public function testRouting()
21
    {
22 1
        $client  = self::createClient();
23 1
        $router  = $client->getContainer()->get('router');
24 1
        $context = new RequestContext();
25 1
        $context->setMethod('POST');
26 1
        $router->setContext($context);
27 1
        $match = $router->match('/test/');
28 1
        self::assertArrayHasKey('_controller', $match);
29 1
        self::assertSame(TestController::class . '::rpcAction', $match['_controller']);
30 1
        self::assertSame('test', $match['_route']);
31 1
    }
32
33 1
    public function testRpcRouterCollection()
34
    {
35 1
        $client = self::createClient();
36
        /** @var Router $router */
37 1
        $router = $client->getContainer()->get('rpc.endpoint_router.test');
38 1
        self::assertNotNull($router);
39
        /** @var MethodCollection $collection */
40 1
        $collection = $router->getCollection();
41 1
        self::assertNotNull($router);
42 1
        self::assertInstanceOf(MethodCollection::class, $collection);
43
44 1
        self::assertTrue($collection->has('test_method'));
45 1
        self::assertSame('test/method', $collection->get('test_method')->getMethod());
46 1
    }
47
48 1
    protected static function getKernelClass()
49
    {
50 1
        return Kernel::class;
51
    }
52
}
53