1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Kitodo\Dlf\Tests\Functional\Repository; |
4
|
|
|
|
5
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\QueryResult; |
6
|
|
|
use Kitodo\Dlf\Domain\Repository\MetadataRepository; |
7
|
|
|
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
8
|
|
|
|
9
|
|
|
class MetadataRepositoryTest extends FunctionalTestCase |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* @var MetadataRepository |
13
|
|
|
*/ |
14
|
|
|
protected $metadataRepository; |
15
|
|
|
|
16
|
|
|
public function setUp(): void |
17
|
|
|
{ |
18
|
|
|
parent::setUp(); |
19
|
|
|
|
20
|
|
|
$this->metadataRepository = $this->initializeRepository( |
21
|
|
|
MetadataRepository::class, |
22
|
|
|
20000 |
23
|
|
|
); |
24
|
|
|
|
25
|
|
|
$this->importDataSet(__DIR__ . '/../../Fixtures/Repository/metadata.xml'); |
|
|
|
|
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* @param $settings |
31
|
|
|
* @return array |
32
|
|
|
*/ |
33
|
|
|
protected function findBySettings($settings) |
34
|
|
|
{ |
35
|
|
|
$metadata = $this->metadataRepository->findBySettings($settings); |
36
|
|
|
$this->assertNotNull($metadata); |
37
|
|
|
$this->assertInstanceOf(QueryResult::class, $metadata); |
38
|
|
|
|
39
|
|
|
$metadataByLabel = []; |
40
|
|
|
foreach ($metadata as $mdata) { |
41
|
|
|
$metadataByLabel[$mdata->getLabel()] = $mdata; |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
return $metadataByLabel; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @test |
49
|
|
|
* @group find |
50
|
|
|
*/ |
51
|
|
|
public function canFindBySettings(): void |
52
|
|
|
{ |
53
|
|
|
$metadataByLabel = $this->findBySettings([]); |
54
|
|
|
$this->assertEquals(6, sizeof($metadataByLabel)); |
55
|
|
|
$this->assertEquals( |
56
|
|
|
'Ort, Untertitel, Autor, Institution, Sammlungen, Titel', |
57
|
|
|
implode(', ', array_keys($metadataByLabel)) |
58
|
|
|
); |
59
|
|
|
|
60
|
|
|
$metadataByLabel = $this->findBySettings(['is_listed' => true]); |
61
|
|
|
$this->assertEquals(3, sizeof($metadataByLabel)); |
62
|
|
|
$this->assertEquals( |
63
|
|
|
'Autor, Institution, Titel', |
64
|
|
|
implode(', ', array_keys($metadataByLabel)) |
65
|
|
|
); |
66
|
|
|
|
67
|
|
|
$metadataByLabel = $this->findBySettings(['is_sortable' => true]); |
68
|
|
|
$this->assertEquals(4, sizeof($metadataByLabel)); |
69
|
|
|
$this->assertEquals( |
70
|
|
|
'Ort, Untertitel, Autor, Titel', |
71
|
|
|
implode(', ', array_keys($metadataByLabel)) |
72
|
|
|
); |
73
|
|
|
|
74
|
|
|
$metadataByLabel = $this->findBySettings([ |
75
|
|
|
'is_sortable' => true, |
76
|
|
|
'is_listed' => true |
77
|
|
|
]); |
78
|
|
|
$this->assertEquals(2, sizeof($metadataByLabel)); |
79
|
|
|
$this->assertEquals( |
80
|
|
|
'Autor, Titel', |
81
|
|
|
implode(', ', array_keys($metadataByLabel)) |
82
|
|
|
); |
83
|
|
|
} |
84
|
|
|
} |
85
|
|
|
|
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.