|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Kitodo\Dlf\Tests\Functional\Common; |
|
4
|
|
|
|
|
5
|
|
|
use Kitodo\Dlf\Common\Helper; |
|
6
|
|
|
use Kitodo\Dlf\Common\Doc; |
|
7
|
|
|
use Kitodo\Dlf\Common\Indexer; |
|
8
|
|
|
use Kitodo\Dlf\Common\Solr; |
|
9
|
|
|
use Kitodo\Dlf\Domain\Model\Collection; |
|
10
|
|
|
use Kitodo\Dlf\Domain\Model\SolrCore; |
|
11
|
|
|
use Kitodo\Dlf\Domain\Repository\CollectionRepository; |
|
12
|
|
|
use Kitodo\Dlf\Domain\Repository\DocumentRepository; |
|
13
|
|
|
use Kitodo\Dlf\Domain\Repository\SolrCoreRepository; |
|
14
|
|
|
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase; |
|
15
|
|
|
use TYPO3\CMS\Core\Core\Bootstrap; |
|
16
|
|
|
use TYPO3\CMS\Core\Utility\GeneralUtility; |
|
17
|
|
|
use TYPO3\CMS\Extbase\Object\ObjectManager; |
|
18
|
|
|
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager; |
|
19
|
|
|
|
|
20
|
|
|
class HelperTest extends FunctionalTestCase |
|
21
|
|
|
{ |
|
22
|
|
|
public function setUp(): void |
|
23
|
|
|
{ |
|
24
|
|
|
parent::setUp(); |
|
25
|
|
|
|
|
26
|
|
|
$this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml'); |
|
27
|
|
|
$this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml'); |
|
28
|
|
|
} |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* @test |
|
32
|
|
|
*/ |
|
33
|
|
|
public function canGetIndexNameFromUid() |
|
34
|
|
|
{ |
|
35
|
|
|
// Repeat to make sure caching isn't broken |
|
36
|
|
|
for ($n = 0; $n < 2; $n++) { |
|
37
|
|
|
// Good UID, no PID |
|
38
|
|
|
$this->assertEquals( |
|
39
|
|
|
'default', |
|
40
|
|
|
Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries') |
|
41
|
|
|
); |
|
42
|
|
|
$this->assertEquals( |
|
43
|
|
|
'title', |
|
44
|
|
|
Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata') |
|
45
|
|
|
); |
|
46
|
|
|
$this->assertEquals( |
|
47
|
|
|
'collection', |
|
48
|
|
|
Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata') |
|
49
|
|
|
); |
|
50
|
|
|
|
|
51
|
|
|
// Good UID, good PID |
|
52
|
|
|
$this->assertEquals( |
|
53
|
|
|
'default', |
|
54
|
|
|
Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 20000) |
|
55
|
|
|
); |
|
56
|
|
|
$this->assertEquals( |
|
57
|
|
|
'title', |
|
58
|
|
|
Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata', 20000) |
|
59
|
|
|
); |
|
60
|
|
|
$this->assertEquals( |
|
61
|
|
|
'collection', |
|
62
|
|
|
Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata', 20000) |
|
63
|
|
|
); |
|
64
|
|
|
|
|
65
|
|
|
// Good UID, bad PID |
|
66
|
|
|
$this->assertEquals( |
|
67
|
|
|
'', |
|
68
|
|
|
Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 123456) |
|
69
|
|
|
); |
|
70
|
|
|
|
|
71
|
|
|
// Bad UID, no PID |
|
72
|
|
|
$this->assertEquals( |
|
73
|
|
|
'', |
|
74
|
|
|
Helper::getIndexNameFromUid(123456, 'tx_dlf_libraries') |
|
75
|
|
|
); |
|
76
|
|
|
} |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|