1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* (c) Kitodo. Key to digital objects e.V. <[email protected]> |
5
|
|
|
* |
6
|
|
|
* This file is part of the Kitodo and TYPO3 projects. |
7
|
|
|
* |
8
|
|
|
* @license GNU General Public License version 3 or later. |
9
|
|
|
* For the full copyright and license information, please read the |
10
|
|
|
* LICENSE.txt file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Kitodo\Dlf\Tests\Functional\Repository; |
14
|
|
|
|
15
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; |
16
|
|
|
use Kitodo\Dlf\Domain\Repository\MetadataRepository; |
17
|
|
|
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
18
|
|
|
|
19
|
|
|
class MetadataRepositoryTest extends FunctionalTestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var MetadataRepository |
23
|
|
|
*/ |
24
|
|
|
protected $metadataRepository; |
25
|
|
|
|
26
|
|
|
public function setUp(): void |
27
|
|
|
{ |
28
|
|
|
parent::setUp(); |
29
|
|
|
|
30
|
|
|
$this->metadataRepository = $this->initializeRepository( |
31
|
|
|
MetadataRepository::class, |
32
|
|
|
20000 |
33
|
|
|
); |
34
|
|
|
|
35
|
|
|
$this->importCSVDataSet(__DIR__ . '/../../Fixtures/Repository/metadata.csv'); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @param $settings |
41
|
|
|
* @return array |
42
|
|
|
*/ |
43
|
|
|
protected function findBySettings($settings) |
44
|
|
|
{ |
45
|
|
|
$metadata = $this->metadataRepository->findBySettings($settings); |
46
|
|
|
self::assertNotNull($metadata); |
47
|
|
|
self::assertInstanceOf(QueryResult::class, $metadata); |
48
|
|
|
|
49
|
|
|
$metadataByLabel = []; |
50
|
|
|
foreach ($metadata as $mdata) { |
51
|
|
|
$metadataByLabel[$mdata->getLabel()] = $mdata; |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
return $metadataByLabel; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @test |
59
|
|
|
* @group find |
60
|
|
|
*/ |
61
|
|
|
public function canFindBySettings(): void |
62
|
|
|
{ |
63
|
|
|
$metadataByLabel = $this->findBySettings([]); |
64
|
|
|
self::assertCount(6, $metadataByLabel); |
65
|
|
|
self::assertEquals( |
66
|
|
|
'Ort, Untertitel, Autor, Institution, Sammlungen, Titel', |
67
|
|
|
implode(', ', array_keys($metadataByLabel)) |
68
|
|
|
); |
69
|
|
|
|
70
|
|
|
$metadataByLabel = $this->findBySettings(['is_listed' => true]); |
71
|
|
|
self::assertCount(3, $metadataByLabel); |
72
|
|
|
self::assertEquals( |
73
|
|
|
'Autor, Institution, Titel', |
74
|
|
|
implode(', ', array_keys($metadataByLabel)) |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
$metadataByLabel = $this->findBySettings(['is_sortable' => true]); |
78
|
|
|
self::assertCount(4, $metadataByLabel); |
79
|
|
|
self::assertEquals( |
80
|
|
|
'Ort, Untertitel, Autor, Titel', |
81
|
|
|
implode(', ', array_keys($metadataByLabel)) |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
$metadataByLabel = $this->findBySettings( |
85
|
|
|
[ |
86
|
|
|
'is_sortable' => true, |
87
|
|
|
'is_listed' => true |
88
|
|
|
] |
89
|
|
|
); |
90
|
|
|
self::assertCount(2, $metadataByLabel); |
91
|
|
|
self::assertEquals( |
92
|
|
|
'Autor, Titel', |
93
|
|
|
implode(', ', array_keys($metadataByLabel)) |
94
|
|
|
); |
95
|
|
|
} |
96
|
|
|
} |
97
|
|
|
|