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.
Completed
Push — master ( c23e92...610884 )
by Sebastian
19s queued 15s
created

HelperTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 87
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 39
c 2
b 0
f 0
dl 0
loc 87
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A canGetIndexNameFromUid() 0 42 2
A setUp() 0 6 1
A canTranslateLanguageNameToGerman() 0 9 1
A canTranslateLanguageNameToEnglish() 0 9 1
1
<?php
2
3
namespace Kitodo\Dlf\Tests\Functional\Common;
4
5
use Kitodo\Dlf\Common\Helper;
6
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
7
use TYPO3\CMS\Core\Localization\LanguageService;
8
9
class HelperTest extends FunctionalTestCase
10
{
11
    public function setUp(): void
12
    {
13
        parent::setUp();
14
15
        $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml');
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\TestingFramework\C...stCase::importDataSet() has been deprecated: Will be removed with core v12 compatible testing-framework. Importing database fixtures based on XML format is discouraged. Switch to CSV format instead. See core functional tests or styleguide for many examples how these look like. Use method importCSVDataSet() to import such fixture files and assertCSVDataSet() to compare database state with fixture files. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

15
        /** @scrutinizer ignore-deprecated */ $this->importDataSet(__DIR__ . '/../../Fixtures/Common/libraries.xml');

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.

Loading history...
16
        $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml');
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\TestingFramework\C...stCase::importDataSet() has been deprecated: Will be removed with core v12 compatible testing-framework. Importing database fixtures based on XML format is discouraged. Switch to CSV format instead. See core functional tests or styleguide for many examples how these look like. Use method importCSVDataSet() to import such fixture files and assertCSVDataSet() to compare database state with fixture files. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

16
        /** @scrutinizer ignore-deprecated */ $this->importDataSet(__DIR__ . '/../../Fixtures/Common/metadata.xml');

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.

Loading history...
17
    }
18
19
    /**
20
     * @test
21
     */
22
    public function canGetIndexNameFromUid()
23
    {
24
        // Repeat to make sure caching isn't broken
25
        for ($n = 0; $n < 2; $n++) {
26
            // Good UID, no PID
27
            $this->assertEquals(
28
                'default',
29
                Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries')
30
            );
31
            $this->assertEquals(
32
                'title',
33
                Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata')
34
            );
35
            $this->assertEquals(
36
                'collection',
37
                Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata')
38
            );
39
40
            // Good UID, good PID
41
            $this->assertEquals(
42
                'default',
43
                Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 20000)
44
            );
45
            $this->assertEquals(
46
                'title',
47
                Helper::getIndexNameFromUid(5001, 'tx_dlf_metadata', 20000)
48
            );
49
            $this->assertEquals(
50
                'collection',
51
                Helper::getIndexNameFromUid(5002, 'tx_dlf_metadata', 20000)
52
            );
53
54
            // Good UID, bad PID
55
            $this->assertEquals(
56
                '',
57
                Helper::getIndexNameFromUid(10001, 'tx_dlf_libraries', 123456)
58
            );
59
60
            // Bad UID, no PID
61
            $this->assertEquals(
62
                '',
63
                Helper::getIndexNameFromUid(123456, 'tx_dlf_libraries')
64
            );
65
        }
66
    }
67
68
    /**
69
     * @test
70
     * @group getLanguageName
71
     */
72
    public function canTranslateLanguageNameToEnglish()
73
    {
74
        // NOTE: This only tests in BE mode
75
76
        $GLOBALS['LANG'] = LanguageService::create('default');
77
        $this->assertEquals('German', Helper::getLanguageName('de')); // ISO 639-1
78
        $this->assertEquals('German', Helper::getLanguageName('ger')); // ISO 639-2
79
        $this->assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex
80
        $this->assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code
81
    }
82
83
    /**
84
     * @test
85
     * @group getLanguageName
86
     */
87
    public function canTranslateLanguageNameToGerman()
88
    {
89
        // NOTE: This only tests in BE mode
90
91
        $GLOBALS['LANG'] = LanguageService::create('de');
92
        $this->assertEquals('Deutsch', Helper::getLanguageName('de')); // ISO 639-1
93
        $this->assertEquals('Deutsch', Helper::getLanguageName('ger')); // ISO 639-2
94
        $this->assertEquals('abcde', Helper::getLanguageName('abcde')); // doesn't match ISO code regex
95
        $this->assertEquals('abc', Helper::getLanguageName('abc')); // matches ISO code regex, but not an ISO code
96
    }
97
}
98