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 (#818)
by
unknown
12:19 queued 08:29
created

MetsDocumentTest::canParseDmdAndAmdSec()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 14
rs 9.9666
c 2
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
            'videoChapter' => [
58
                'fileId' => 'FILE_0000_DEFAULT_MOV',
59
                'timecode' => 0,
60
            ],
61
            'children' => [
62
                [
63
                    'id' => 'LOG_0001',
64
                    'dmdId' => '',
65
                    'admId' => '',
66
                    'videoChapter' => [
67
                        'fileId' => 'FILE_0000_DEFAULT_MOV',
68
                        'timecode' => 0,
69
                    ],
70
                ],
71
                [
72
                    'id' => 'LOG_0002',
73
                    'dmdId' => '',
74
                    'admId' => '',
75
                    'videoChapter' => [
76
                        'fileId' => 'FILE_0000_DEFAULT_MOV',
77
                        'timecode' => 20.5,
78
                    ],
79
                ],
80
                [
81
                    'id' => 'LOG_0003',
82
                    'dmdId' => '',
83
                    'admId' => '',
84
                    'videoChapter' => [
85
                        'fileId' => 'FILE_0000_DEFAULT_MOV',
86
                        'timecode' => 40,
87
                    ],
88
                ],
89
                [
90
                    'id' => 'LOG_0004',
91
                    'dmdId' => '',
92
                    'admId' => '',
93
                    'videoChapter' => [
94
                        'fileId' => 'FILE_0000_DEFAULT_MOV',
95
                        'timecode' => 60,
96
                    ],
97
                ],
98
            ],
99
        ], $toc, 'Expected TOC to contain the specified values');
100
    }
101
102
    /**
103
     * @test
104
     */
105
    public function canReadChapterArea()
106
    {
107
        $doc = $this->doc('av_beispiel.xml');
108
109
        $ch3_page = $doc->physicalStructureInfo[$doc->physicalStructure[3]];
110
        $this->assertArrayMatches([
111
            'DEFAULT' => 'FILE_0000_DEFAULT_MP4',
112
        ], $ch3_page['files']);
113
        $this->assertArrayMatches([
114
            'DEFAULT' => [
115
                'FILE_0000_DEFAULT_MOV',
116
                'FILE_0000_DEFAULT_MP4',
117
            ],
118
        ], $ch3_page['all_files']);
119
        $this->assertArrayMatches([
120
            'FILE_0000_DEFAULT_MP4' => [
121
                'area' => [
122
                    'begin' => '00:00:40',
123
                    'betype' => 'TIME',
124
                    'extent' => '00:00:20',
125
                    'exttype' => 'TIME',
126
                ],
127
            ],
128
        ], $ch3_page['fileInfos']);
129
    }
130
131
    /**
132
     * @test
133
     */
134
    public function doesNotOverwriteFirstDmdSec()
135
    {
136
        $doc = $this->doc('two_dmdsec.xml');
137
138
        $titledata = $doc->getTitledata(20000);
139
        $toc = $doc->tableOfContents[0] ?? [];
140
141
        $this->assertEquals('DMDLOG_0000 DMDLOG_0000b', $toc['dmdId']); // TODO: Do we want the raw (non-split) value here?
142
        $this->assertEquals('Test Value in DMDLOG_0000', $titledata['test_value'][0]);
143
    }
144
145
    /**
146
     * @test
147
     */
148
    public function returnsEmptyMetadataWhenNoDmdSec()
149
    {
150
        $doc = $this->doc('two_dmdsec.xml');
151
152
        // DMD and AMD works
153
        $metadata = $doc->getMetadata('LOG_0000', 20000);
154
        $this->assertEquals('Test Value in DMDLOG_0000', $metadata['test_value'][0]);
155
156
        // DMD only works
157
        $metadata = $doc->getMetadata('LOG_0001', 20000);
158
        $this->assertEquals(['Test Value in DMDLOG_0000b'], $metadata['test_value']);
159
160
        // AMD only does not work
161
        $metadata = $doc->getMetadata('LOG_0002', 20000);
162
        $this->assertEquals([], $metadata);
163
    }
164
}
165