1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OpenOrchestra\FunctionalTests\ModelLogBundle\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 LogRepositoryTest |
11
|
|
|
* |
12
|
|
|
* @group integrationTest |
13
|
|
|
*/ |
14
|
|
|
class LogRepositoryTest 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_log.repository.log'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* test findForPaginate |
34
|
|
|
* |
35
|
|
|
* @param PaginateFinderConfiguration $configuration |
36
|
|
|
* @param int $expectedCount |
37
|
|
|
* @param int $expectedFilteredCount |
38
|
|
|
* |
39
|
|
|
* @dataProvider providePaginateConfiguration |
40
|
|
|
*/ |
41
|
|
|
public function testFindForPaginate(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
|
|
|
|
42
|
|
|
{ |
43
|
|
|
$this->assertCount($expectedCount, $this->repository->findForPaginate($configuration)); |
44
|
|
|
} |
45
|
|
|
|
46
|
|
|
/** |
47
|
|
|
* Provide PaginateFinderConfiguration |
48
|
|
|
* |
49
|
|
|
* @return array |
50
|
|
|
*/ |
51
|
|
|
public function providePaginateConfiguration() |
52
|
|
|
{ |
53
|
|
|
$mapping = array( |
54
|
|
|
'date_time' => 'datetime', |
55
|
|
|
'user_ip' => 'extra.user_ip', |
56
|
|
|
'user_name' => 'extra.user_name', |
57
|
|
|
'message' => 'message' |
58
|
|
|
); |
59
|
|
|
$conf1 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array( |
60
|
|
|
'site_id' => 'fixture' |
61
|
|
|
)); |
62
|
|
|
$conf2 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array( |
63
|
|
|
'site_id' => 'fixture', 'date' => '2016/02/10', 'date-format' => 'yy/mm/dd' |
64
|
|
|
)); |
65
|
|
|
$conf3 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array( |
66
|
|
|
'site_id' => 'fixture', 'user_ip' => '5' |
67
|
|
|
)); |
68
|
|
|
$conf4 = PaginateFinderConfiguration::generateFromVariable(null , null, null, $mapping, array( |
69
|
|
|
'site_id' => 'fixture', 'user_name' => 'developer' |
70
|
|
|
)); |
71
|
|
|
|
72
|
|
|
return array( |
73
|
|
|
'No criteria' => array($conf1, 9, 9), |
74
|
|
|
'Filtering on date' => array($conf2, 5, 5), |
75
|
|
|
'Filtering ip' => array($conf3, 3, 3), |
76
|
|
|
'Filtering name' => array($conf4, 4, 4), |
77
|
|
|
); |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
/** |
81
|
|
|
* test count |
82
|
|
|
*/ |
83
|
|
|
public function testCount() |
84
|
|
|
{ |
85
|
|
|
$this->assertSame(61, $this->repository->count()); |
86
|
|
|
} |
87
|
|
|
|
88
|
|
|
/** |
89
|
|
|
* test countWithFilter |
90
|
|
|
* |
91
|
|
|
* @param PaginateFinderConfiguration $configuration |
92
|
|
|
* @param int $expectedCount |
93
|
|
|
* @param int $expectedFilteredCount |
94
|
|
|
* |
95
|
|
|
* @dataProvider providePaginateConfiguration |
96
|
|
|
*/ |
97
|
|
|
public function testCountWithFilter(PaginateFinderConfiguration $configuration, $expectedCount, $expectedFilteredCount) |
|
|
|
|
98
|
|
|
{ |
99
|
|
|
$this->assertSame($expectedFilteredCount, $this->repository->countWithFilter($configuration)); |
100
|
|
|
} |
101
|
|
|
} |
102
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.