1
|
<?php
|
2
|
|
3
|
namespace App\Test\Repository;
|
4
|
|
5
|
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;
|
6
|
use App\Repository\OpenDataManager;
|
7
|
|
8
|
class OpenDataManagerTest extends KernelTestCase {
|
9
|
private $manager;
|
10
|
|
11
|
protected function setUp(): void {
|
12
|
$kernel = self::bootKernel();
|
13
|
$this->manager = $kernel->getContainer()->get('App\Repository\IOpenDataManager');
|
14
|
}
|
15
|
|
16
|
public function testGetCollectionDataByName() {
|
17
|
$this->assertFalse(empty($this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')));
|
18
|
$this->assertTrue(array_key_exists('number', $this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')[0]));
|
19
|
$this->assertTrue(array_key_exists('place', $this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')[0]));
|
20
|
$this->assertTrue(array_key_exists('x', $this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')[0]));
|
21
|
$this->assertTrue(array_key_exists('y', $this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')[0]));
|
22
|
$this->assertTrue(array_key_exists('date', $this->manager->getCollectionDataByName('KOLOBEZKY', '2019-04-11', '9')[0]));
|
23
|
}
|
24
|
|
25
|
public function testGetCollectionDataByNameInvalid() {
|
26
|
$this->assertTrue(empty($this->manager->getCollectionDataByName(null, null, null)));
|
27
|
$this->assertTrue(empty($this->manager->getCollectionDataByName('NIC', '2019-04-11', '9')));
|
28
|
$this->assertTrue(empty($this->manager->getCollectionDataByName('NIC', '11-04-2020', '9')));
|
29
|
$this->assertTrue(empty($this->manager->getCollectionDataByName('NIC', '2019-04-11', '25')));
|
30
|
}
|
31
|
|
32
|
public function testAvailableCollections() {
|
33
|
$this->assertFalse(empty($this->manager->getAvailableCollections()));
|
34
|
}
|
35
|
|
36
|
public function testGetAvailableCollectionsByDay() {
|
37
|
$this->assertFalse(empty($this->manager->getAvailableCollectionsByDay('2019-04-11')));
|
38
|
}
|
39
|
|
40
|
public function testGetAvailableCollectionsByDayInvalid() {
|
41
|
$this->assertTrue(empty($this->manager->getAvailableCollectionsByDay(null)));
|
42
|
$this->assertTrue(empty($this->manager->getAvailableCollectionsByDay('11-04-2020')));
|
43
|
}
|
44
|
|
45
|
public function testIsCollectionAvailable() {
|
46
|
$this->assertTrue($this->manager->isCollectionAvailable('KOLOBEZKY', '2019-04-11'));
|
47
|
$this->assertFalse($this->manager->isCollectionAvailable('KOLOBEZKY', '2000-04-11'));
|
48
|
}
|
49
|
|
50
|
public function testIsCollectionAvailableInvalid() {
|
51
|
$this->assertFalse($this->manager->isCollectionAvailable(null, null));
|
52
|
$this->assertFalse($this->manager->isCollectionAvailable('NIC', '2019-04-11'));
|
53
|
$this->assertFalse($this->manager->isCollectionAvailable('KOLOBEZKY', '11-04-2019'));
|
54
|
}
|
55
|
|
56
|
public function testGetDatesWithAvailableCollection() {
|
57
|
$this->assertFalse(empty($this->manager->getDatesWithAvailableCollection()));
|
58
|
$this->assertRegExp('/^(\d{4})-(\d{2})-(\d{2})/', $this->manager->getDatesWithAvailableCollection()[0]);
|
59
|
}
|
60
|
|
61
|
public function testGetLastAvailableCollections() {
|
62
|
$this->assertFalse(empty($this->manager->getLastAvailableCollections()));
|
63
|
$this->assertRegExp('/^(\d{4})-(\d{2})-(\d{2})/', $this->manager->getLastAvailableCollections()['KOLOBEZKY']);
|
64
|
}
|
65
|
|
66
|
public function testGetMaxCollectionNumberAtDay() {
|
67
|
$this->assertGreaterThan(0, $this->manager->getMaxCollectionNumberAtDay('KOLOBEZKY', '2019-04-11'));
|
68
|
}
|
69
|
|
70
|
public function testGetMaxCollectionNumberAtDayInvalid() {
|
71
|
$this->assertEquals(0, $this->manager->getMaxCollectionNumberAtDay(null, null));
|
72
|
$this->assertEquals(0, $this->manager->getMaxCollectionNumberAtDay('NIC', '2019-04-11'));
|
73
|
$this->assertEquals(0, $this->manager->getMaxCollectionNumberAtDay('KOLOBEZKY', '11-04-2019'));
|
74
|
}
|
75
|
|
76
|
public function testGetDataSourcePositions() {
|
77
|
$this->assertFalse(empty($this->manager->getDataSourcePositions('KOLOBEZKY')));
|
78
|
$this->assertTrue(array_key_exists('x', $this->manager->getDataSourcePositions('KOLOBEZKY')[0]));
|
79
|
$this->assertTrue(array_key_exists('y', $this->manager->getDataSourcePositions('KOLOBEZKY')[0]));
|
80
|
}
|
81
|
|
82
|
public function testGetDataSourcePositionsInvalid() {
|
83
|
$this->assertTrue(empty($this->manager->getDataSourcePositions(null)));
|
84
|
$this->assertTrue(empty($this->manager->getDataSourcePositions('NIC')));
|
85
|
}
|
86
|
}
|