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

RoutingTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 3
c 1
b 1
f 0
lcom 1
cbo 6
dl 0
loc 35
ccs 23
cts 23
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testRouting() 0 12 1
A testRpcRouterCollection() 0 14 1
A getKernelClass() 0 4 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