|
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\DoctrineORMAdminBundle\Tests\Builder; |
|
13
|
|
|
|
|
14
|
|
|
use Sonata\AdminBundle\Datagrid\Pager; |
|
15
|
|
|
use Sonata\AdminBundle\Filter\FilterFactoryInterface; |
|
16
|
|
|
use Sonata\AdminBundle\Guesser\TypeGuesserInterface; |
|
17
|
|
|
use Sonata\DoctrineORMAdminBundle\Builder\DatagridBuilder; |
|
18
|
|
|
use Symfony\Component\Form\FormFactoryInterface; |
|
19
|
|
|
|
|
20
|
|
|
/** |
|
21
|
|
|
* @author Sullivan Senechal <[email protected]> |
|
22
|
|
|
*/ |
|
23
|
|
|
final class DatagridBuilderTest extends \PHPUnit_Framework_TestCase |
|
24
|
|
|
{ |
|
25
|
|
|
/** |
|
26
|
|
|
* @var TypeGuesserInterface|\PHPUnit_Framework_MockObject_MockObject |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $typeGuesser; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @var DatagridBuilder |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $datagridBuilder; |
|
34
|
|
|
/** |
|
35
|
|
|
* @var FormFactoryInterface|\PHPUnit_Framework_MockObject_MockObject |
|
36
|
|
|
*/ |
|
37
|
|
|
private $formFactory; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* @var FilterFactoryInterface|\PHPUnit_Framework_MockObject_MockObject |
|
41
|
|
|
*/ |
|
42
|
|
|
private $filterFactory; |
|
43
|
|
|
|
|
44
|
|
|
protected function setUp() |
|
45
|
|
|
{ |
|
46
|
|
|
$this->formFactory = $this->getMock('Symfony\Component\Form\FormFactoryInterface'); |
|
47
|
|
|
$this->filterFactory = $this->getMock('Sonata\AdminBundle\Filter\FilterFactoryInterface'); |
|
48
|
|
|
$this->typeGuesser = $this->getMock('Sonata\AdminBundle\Guesser\TypeGuesserInterface'); |
|
49
|
|
|
|
|
50
|
|
|
$this->datagridBuilder = new DatagridBuilder($this->formFactory, $this->filterFactory, $this->typeGuesser); |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testGetBaseDatagrid() |
|
54
|
|
|
{ |
|
55
|
|
|
$admin = $this->getMockBuilder('Sonata\AdminBundle\Admin\AbstractAdmin') |
|
56
|
|
|
->disableOriginalConstructor()->getMock(); |
|
57
|
|
|
$admin->expects($this->once())->method('getPagerType')->willReturn(Pager::TYPE_SIMPLE); |
|
58
|
|
|
$admin->expects($this->once())->method('getClass')->willReturn('Foo\Bar'); |
|
59
|
|
|
$admin->expects($this->once())->method('createQuery') |
|
60
|
|
|
->willReturn($this->getMock('Sonata\AdminBundle\Datagrid\ProxyQueryInterface')); |
|
61
|
|
|
$admin->expects($this->once())->method('getList') |
|
62
|
|
|
->willReturn($this->getMock('Sonata\AdminBundle\Admin\FieldDescriptionCollection')); |
|
63
|
|
|
|
|
64
|
|
|
$modelManager = $this->getMock('Sonata\AdminBundle\Model\ModelManagerInterface'); |
|
65
|
|
|
$modelManager->expects($this->once())->method('getIdentifierFieldNames')->willReturn(array('id')); |
|
66
|
|
|
$admin->expects($this->once())->method('getModelManager')->willReturn($modelManager); |
|
67
|
|
|
|
|
68
|
|
|
$this->formFactory->expects($this->once())->method('createNamedBuilder') |
|
|
|
|
|
|
69
|
|
|
->willReturn($this->getMock('Symfony\Component\Form\FormBuilderInterface')); |
|
70
|
|
|
|
|
71
|
|
|
$this->assertInstanceOf('Sonata\AdminBundle\Datagrid\Datagrid', $this->datagridBuilder->getBaseDatagrid($admin)); |
|
72
|
|
|
} |
|
73
|
|
|
} |
|
74
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.