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
04:15
created

returnsEmptyMetadataWhenNoDmdSec()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 7
nc 1
nop 0
dl 0
loc 15
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 canReadFileMetadata()
49
    {
50
        $doc = $this->doc('av_beispiel.xml');
51
52
        $thumbsMeta = $doc->getMetadata('FILE_0000_THUMBS', 20000);
53
        $this->assertEquals($thumbsMeta, []);
54
55
        $videoMeta = $doc->getMetadata('FILE_0000_DEFAULT', 20000);
56
        $this->assertArrayMatches([
57
            'frame_rate' => ['24'],
58
        ], $videoMeta);
59
    }
60
61
    /**
62
     * @test
63
     */
64
    public function canGetLogicalStructure()
65
    {
66
        $doc = $this->doc('av_beispiel.xml');
67
68
        $toc = $doc->tableOfContents[0] ?? [];
69
70
        $this->assertArrayMatches([
71
            'dmdId' => 'DMDLOG_0000',
72
            'admId' => 'AMD',
73
            'children' => [
74
                [
75
                    'id' => 'LOG_0001',
76
                    'dmdId' => '',
77
                    'admId' => '',
78
                ],
79
                [
80
                    'id' => 'LOG_0002',
81
                    'dmdId' => '',
82
                    'admId' => '',
83
                ],
84
                [
85
                    'id' => 'LOG_0003',
86
                    'dmdId' => '',
87
                    'admId' => '',
88
                ],
89
                [
90
                    'id' => 'LOG_0004',
91
                    'dmdId' => '',
92
                    'admId' => '',
93
                ],
94
            ],
95
        ], $toc, 'Expected TOC to contain the specified values');
96
    }
97
98
    /**
99
     * @test
100
     */
101
    public function doesNotOverwriteFirstDmdSec()
102
    {
103
        $doc = $this->doc('two_dmdsec.xml');
104
105
        $titledata = $doc->getTitledata(20000);
106
        $toc = $doc->tableOfContents[0] ?? [];
107
108
        $this->assertEquals('DMDLOG_0000 DMDLOG_0000b', $toc['dmdId']); // TODO: Do we want the raw (non-split) value here?
109
        $this->assertEquals('Test Value in DMDLOG_0000', $titledata['test_value'][0]);
110
    }
111
112
    /**
113
     * @test
114
     */
115
    public function returnsEmptyMetadataWhenNoDmdSec()
116
    {
117
        $doc = $this->doc('two_dmdsec.xml');
118
119
        // DMD and AMD works
120
        $metadata = $doc->getMetadata('LOG_0000', 20000);
121
        $this->assertEquals('Test Value in DMDLOG_0000', $metadata['test_value'][0]);
122
123
        // DMD only works
124
        $metadata = $doc->getMetadata('LOG_0001', 20000);
125
        $this->assertEquals(['Test Value in DMDLOG_0000b'], $metadata['test_value']);
126
127
        // AMD only does not work
128
        $metadata = $doc->getMetadata('LOG_0002', 20000);
129
        $this->assertEquals([], $metadata);
130
    }
131
}
132