Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Passed
Pull Request — master (#796)
by
unknown
09:00
created

MetsDocumentTest::doc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Kitodo\Dlf\Tests\Functional\Common;
4
5
use Kitodo\Dlf\Common\Doc;
6
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
7
8
class MetsDocumentTest extends FunctionalTestCase
9
{
10
    public function setUp(): void
11
    {
12
        parent::setUp();
13
14
        $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml');
15
        $this->importDataSet(__DIR__ . '/../../Fixtures/MetsDocument/metadata_mets.xml');
16
    }
17
18
    protected function doc(string $file)
19
    {
20
        $url = 'http://web:8001/Tests/Fixtures/MetsDocument/' . $file;
21
        $doc = Doc::getInstance($url);
22
        $this->assertNotNull($doc);
23
        return $doc;
24
    }
25
26
    /**
27
     * @test
28
     */
29
    public function canParseDmdAndAmdSec()
30
    {
31
        $doc = $this->doc('av_beispiel.xml');
32
33
        $titledata = $doc->getTitledata(20000);
34
35
        $this->assertEquals(['Odol-Mundwasser, 3 Werbespots'], $titledata['title']);
36
        $this->assertEquals(['24'], $titledata['frame_rate']);
37
        $this->assertEquals(['Sächsische Landesbibliothek - Staats- und Universitätsbibliothek Dresden'], $titledata['dvrights_owner']);
38
        $this->assertEquals(['https://katalog.slub-dresden.de/id/0-1703800435'], $titledata['dvlinks_reference']);
39
40
        $this->assertEquals([
41
            'DMDLOG_0000' => $doc->mdSec['DMDLOG_0000'],
0 ignored issues
show
Bug Best Practice introduced by
The property mdSec does not exist on Kitodo\Dlf\Common\Doc. Since you implemented __get, consider adding a @property annotation.
Loading history...
42
        ], $doc->dmdSec);
0 ignored issues
show
Bug Best Practice introduced by
The property dmdSec does not exist on Kitodo\Dlf\Common\Doc. Since you implemented __get, consider adding a @property annotation.
Loading history...
43
    }
44
45
    /**
46
     * @test
47
     */
48
    public function canGetLogicalStructure()
49
    {
50
        $doc = $this->doc('av_beispiel.xml');
51
52
        $toc = $doc->tableOfContents[0] ?? [];
53
54
        $this->assertArrayMatches([
55
            'dmdId' => 'DMDLOG_0000',
56
            'admId' => 'AMD',
57
            'children' => [
58
                [
59
                    'id' => 'LOG_0001',
60
                    'dmdId' => '',
61
                    'admId' => '',
62
                ],
63
                [
64
                    'id' => 'LOG_0002',
65
                    'dmdId' => '',
66
                    'admId' => '',
67
                ],
68
                [
69
                    'id' => 'LOG_0003',
70
                    'dmdId' => '',
71
                    'admId' => '',
72
                ],
73
                [
74
                    'id' => 'LOG_0004',
75
                    'dmdId' => '',
76
                    'admId' => '',
77
                ],
78
            ],
79
        ], $toc, 'Expected TOC to contain the specified values');
80
    }
81
82
    /**
83
     * @test
84
     */
85
    public function doesNotOverwriteFirstDmdSec()
86
    {
87
        $doc = $this->doc('two_dmdsec.xml');
88
89
        $titledata = $doc->getTitledata(20000);
90
        $toc = $doc->tableOfContents[0] ?? [];
91
92
        $this->assertEquals('DMDLOG_0000 DMDLOG_0000b', $toc['dmdId']); // TODO: Do we want the raw (non-split) value here?
93
        $this->assertEquals('Test Value in DMDLOG_0000', $titledata['test_value'][0]);
94
    }
95
96
    /**
97
     * @test
98
     */
99
    public function returnsEmptyMetadataWhenNoDmdSec()
100
    {
101
        $doc = $this->doc('two_dmdsec.xml');
102
103
        // DMD and AMD works
104
        $metadata = $doc->getMetadata('LOG_0000', 20000);
105
        $this->assertEquals('Test Value in DMDLOG_0000', $metadata['test_value'][0]);
106
107
        // DMD only works
108
        $metadata = $doc->getMetadata('LOG_0001', 20000);
109
        $this->assertEquals(['Test Value in DMDLOG_0000b'], $metadata['test_value']);
110
111
        // AMD only does not work
112
        $metadata = $doc->getMetadata('LOG_0002', 20000);
113
        $this->assertEquals([], $metadata);
114
    }
115
}
116