Completed
Push — 3.x ( de469d...59ade0 )
by Grégoire
04:08
created

RouteIdHandlerTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 1
dl 0
loc 24
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A testGetIdFromRequest() 0 21 1
1
<?php
2
3
/*
4
 * This file is part of the Sonata Project package.
5
 *
6
 * (c) Thomas Rabaix <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sonata\AdminBundle\Tests\Route;
13
14
use Sonata\AdminBundle\Route\Handler\RouteIdHandler;
15
16
class RouteIdHandlerTest extends \PHPUnit_Framework_TestCase
17
{
18
    public function testGetIdFromRequest()
19
    {
20
        $idParameter = 'id';
21
        $requestId = 1;
22
23
        $adminInterface = $this->getMockForAbstractClass('Sonata\AdminBundle\Admin\AdminInterface');
24
        $adminInterface->expects($this->once())
25
            ->method('getIdParameter')
26
            ->will($this->returnValue($idParameter));
27
28
        $request = $this->getMockBuilder('Symfony\Component\HttpFoundation\Request')
29
            ->getMock();
30
        $request->expects($this->once())
31
            ->method('get')
32
            ->with($idParameter)
33
            ->will($this->returnValue($requestId));
34
35
        $routeIdHandler = new RouteIdHandler();
36
        $returnId = $routeIdHandler->getIdFromRequest($request, $adminInterface);
37
        $this->assertEquals($requestId, $returnId);
38
    }
39
}
40