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

RouteIdHandlerTest::testGetIdFromRequest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 9.3142
c 0
b 0
f 0
cc 1
eloc 16
nc 1
nop 0
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