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(4, $statuses); |
39
|
|
|
foreach ($statuses as $status) { |
40
|
|
|
$this->assertFalse($status->isOutOfWorkflow()); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** |
45
|
|
|
* test find other by translation state |
46
|
|
|
*/ |
47
|
|
|
public function testFindOtherByTranslationState() |
48
|
|
|
{ |
49
|
|
|
$statuses = $this->repository->findOtherByTranslationState('toTranslate'); |
50
|
|
|
$this->assertCount(0, $statuses); |
51
|
|
|
} |
52
|
|
|
|
53
|
|
|
/** |
54
|
|
|
* test find one by translation state |
55
|
|
|
*/ |
56
|
|
|
public function testFindOneByTranslationState() |
57
|
|
|
{ |
58
|
|
|
$status = $this->repository->findOneByTranslationState(); |
59
|
|
|
$this->assertTrue($status->isTranslationState()); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* test findForPaginate |
64
|
|
|
* |
65
|
|
|
* @param PaginateFinderConfiguration $configuration |
66
|
|
|
* @param int $expectedCount |
67
|
|
|
* @param int $expectedFilteredCount |
68
|
|
|
* |
69
|
|
|
* @dataProvider providePaginateConfiguration |
70
|
|
|
*/ |
71
|
|
|
public function testFindForPaginate(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
|
|
|
|
72
|
|
|
{ |
73
|
|
|
$this->assertCount($expectedCount, $this->repository->findForPaginate($configuration)); |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
/** |
77
|
|
|
* test count |
78
|
|
|
*/ |
79
|
|
|
public function testCount() |
80
|
|
|
{ |
81
|
|
|
$this->assertSame(5, $this->repository->count()); |
82
|
|
|
} |
83
|
|
|
|
84
|
|
|
/** |
85
|
|
|
* test countWithFilter |
86
|
|
|
* |
87
|
|
|
* @param PaginateFinderConfiguration $configuration |
88
|
|
|
* @param int $expectedCount |
89
|
|
|
* @param int $expectedFilteredCount |
90
|
|
|
* |
91
|
|
|
* @dataProvider providePaginateConfiguration |
92
|
|
|
*/ |
93
|
|
|
public function testCountWithFilter(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
|
|
|
|
94
|
|
|
{ |
95
|
|
|
$this->assertSame($expectedFilteredCount, $this->repository->countWithFilter($configuration)); |
96
|
|
|
} |
97
|
|
|
|
98
|
|
|
/** |
99
|
|
|
* Provide PaginateFinderConfiguration |
100
|
|
|
* |
101
|
|
|
* @return array |
102
|
|
|
*/ |
103
|
|
|
public function providePaginateConfiguration() |
104
|
|
|
{ |
105
|
|
|
$mapping = array('label' => 'labels'); |
106
|
|
|
$conf1 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, null); |
107
|
|
|
$conf2 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array('label' => 'o', 'language' => 'en')); |
108
|
|
|
$conf3 = PaginateFinderConfiguration::generateFromVariable(null , 2 , 4 , $mapping, array('label' => 'r', 'language' => 'en')); |
109
|
|
|
|
110
|
|
|
return array( |
111
|
|
|
'No criteria' => array($conf1, 5, 5), |
112
|
|
|
'Filtering "o"' => array($conf2, 2, 2), |
113
|
|
|
'Filtering 2 items with "r"' => array($conf3, 1, 3), |
114
|
|
|
); |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.