These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | namespace OpenOrchestra\FunctionalTests\ModelBundle\Repository; |
||
4 | |||
5 | use OpenOrchestra\BaseBundle\Tests\AbstractTest\AbstractKernelTestCase; |
||
6 | use OpenOrchestra\ModelBundle\Repository\StatusRepository; |
||
7 | use OpenOrchestra\Pagination\Configuration\PaginateFinderConfiguration; |
||
8 | |||
9 | /** |
||
10 | * Test StatusRepositoryTest |
||
11 | * |
||
12 | * @group integrationTest |
||
13 | */ |
||
14 | class StatusRepositoryTest extends AbstractKernelTestCase |
||
15 | { |
||
16 | /** |
||
17 | * @var StatusRepository |
||
18 | */ |
||
19 | protected $repository; |
||
20 | |||
21 | /** |
||
22 | * Set up the test |
||
23 | */ |
||
24 | public function setUp() |
||
25 | { |
||
26 | parent::setUp(); |
||
27 | |||
28 | static::bootKernel(); |
||
29 | $this->repository = static::$kernel->getContainer()->get('open_orchestra_model.repository.status'); |
||
30 | } |
||
31 | |||
32 | /** |
||
33 | * test find not out of workflow |
||
34 | */ |
||
35 | public function testFindNotOutOfWorkflow() |
||
36 | { |
||
37 | $statuses = $this->repository->findNotOutOfWorkflow(); |
||
38 | $this->assertCount(5, $statuses); |
||
39 | foreach ($statuses as $status) { |
||
40 | $this->assertFalse($status->isOutOfWorkflow()); |
||
41 | } |
||
42 | } |
||
43 | |||
44 | /** |
||
45 | * test find one by translation state |
||
46 | */ |
||
47 | public function testFindOneByTranslationState() |
||
48 | { |
||
49 | $status = $this->repository->findOneByTranslationState(); |
||
50 | $this->assertTrue($status->isTranslationState()); |
||
51 | } |
||
52 | |||
53 | /** |
||
54 | * test findForPaginate |
||
55 | * |
||
56 | * @param PaginateFinderConfiguration $configuration |
||
57 | * @param int $expectedCount |
||
58 | * @param int $expectedFilteredCount |
||
59 | * |
||
60 | * @dataProvider providePaginateConfiguration |
||
61 | */ |
||
62 | public function testFindForPaginate(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
||
0 ignored issues
–
show
|
|||
63 | { |
||
64 | $this->assertCount($expectedCount, $this->repository->findForPaginate($configuration)); |
||
65 | } |
||
66 | |||
67 | /** |
||
68 | * test count |
||
69 | */ |
||
70 | public function testCountNotOutOfWorkflow() |
||
71 | { |
||
72 | $this->assertSame(5, $this->repository->CountNotOutOfWorkflow()); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * test countWithFilter |
||
77 | * |
||
78 | * @param PaginateFinderConfiguration $configuration |
||
79 | * @param int $expectedCount |
||
80 | * @param int $expectedFilteredCount |
||
81 | * |
||
82 | * @dataProvider providePaginateConfiguration |
||
83 | */ |
||
84 | public function testCountWithFilter(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
||
0 ignored issues
–
show
|
|||
85 | { |
||
86 | $this->assertSame($expectedFilteredCount, $this->repository->countWithFilter($configuration)); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Provide PaginateFinderConfiguration |
||
91 | * |
||
92 | * @return array |
||
93 | */ |
||
94 | public function providePaginateConfiguration() |
||
95 | { |
||
96 | $mapping = array('label' => 'labels'); |
||
97 | $conf1 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, null); |
||
98 | $conf2 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array('label' => 'o', 'language' => 'en')); |
||
99 | $conf3 = PaginateFinderConfiguration::generateFromVariable(null , 2 , 4 , $mapping, array('label' => 'r', 'language' => 'en')); |
||
100 | |||
101 | return array( |
||
102 | 'No criteria' => array($conf1, 5, 5), |
||
103 | 'Filtering "o"' => array($conf2, 2, 2), |
||
104 | 'Filtering 2 items with "r"' => array($conf3, 0, 2), |
||
105 | ); |
||
106 | } |
||
107 | |||
108 | /** |
||
109 | * Test remove statuses |
||
110 | */ |
||
111 | View Code Duplication | public function testRemoveStatuses() |
|
112 | { |
||
113 | $dm = static::$kernel->getContainer()->get('object_manager'); |
||
114 | $statusPending = $this->repository->findOneByName('pending'); |
||
115 | $statusPublished = $this->repository->findOneByName('published'); |
||
116 | |||
117 | $statusIds = array($statusPending->getId(), $statusPublished->getId()); |
||
118 | |||
119 | $this->repository->removeStatuses($statusIds); |
||
120 | $this->assertNull($this->repository->findOneByName('pending')); |
||
121 | $this->assertNull($this->repository->findOneByName('published')); |
||
122 | |||
123 | $dm->persist(clone $statusPending); |
||
124 | $dm->persist(clone $statusPublished); |
||
125 | $dm->flush(); |
||
126 | } |
||
127 | } |
||
128 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.