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.

Issues (214)

Tests/Functional/FunctionalTestCase.php (1 issue)

1
<?php
2
3
/**
4
 * (c) Kitodo. Key to digital objects e.V. <[email protected]>
5
 *
6
 * This file is part of the Kitodo and TYPO3 projects.
7
 *
8
 * @license GNU General Public License version 3 or later.
9
 * For the full copyright and license information, please read the
10
 * LICENSE.txt file that was distributed with this source code.
11
 */
12
13
namespace Kitodo\Dlf\Tests\Functional;
14
15
use Dotenv\Dotenv;
16
use GuzzleHttp\Client as HttpClient;
17
use Kitodo\Dlf\Common\Solr\Solr;
18
use Symfony\Component\Yaml\Yaml;
19
use TYPO3\CMS\Core\Localization\LanguageServiceFactory;
20
use TYPO3\CMS\Core\Utility\ArrayUtility;
21
use TYPO3\CMS\Core\Utility\GeneralUtility;
22
use TYPO3\CMS\Extbase\Object\ObjectManager;
23
use TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager;
24
use TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings;
25
26
/**
27
 * Base class for functional test cases. This provides some common configuration
28
 * and collects utility methods for functional tests.
29
 */
30
class FunctionalTestCase extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
31
{
32
    protected $testExtensionsToLoad = [
33
        'typo3conf/ext/dlf',
34
    ];
35
36
    protected $configurationToUseInTestInstance = [
37
        'SYS' => [
38
            'caching' => [
39
                'cacheConfigurations' => [
40
                    'tx_dlf_doc' => [
41
                        'backend' => \TYPO3\CMS\Core\Cache\Backend\NullBackend::class,
42
                    ],
43
                ],
44
            ],
45
            'displayErrors' => '1'
46
        ],
47
        'SC_OPTIONS' => [
48
            'dlf/Classes/Plugin/Toolbox.php' => []
49
        ],
50
        'EXTENSIONS' => [
51
            'dlf' => [], // = $this->getDlfConfiguration(), set in constructor
52
        ],
53
        'FE' => [
54
            'cacheHash' => [
55
                'enforceValidation' => false,
56
            ],
57
        ],
58
        'DB' => [
59
            'Connections' => [
60
                'Default' => [
61
                    // TODO: This is taken from the base class, minus "ONLY_FULL_GROUP_BY"; should probably rather be changed in DocumentRepository::getOaiDocumentList
62
                    'initCommands' => 'SET SESSION sql_mode = \'STRICT_ALL_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_VALUE_ON_ZERO,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE\';',
63
                ],
64
            ],
65
        ],
66
    ];
67
68
    /**
69
     * By default, the testing framework wraps responses into a JSON object
70
     * that contains status code etc. as fields. Set this field to true to avoid
71
     * this behavior by not loading the json_response extension.
72
     *
73
     * @var bool
74
     */
75
    protected $disableJsonWrappedResponse = false;
76
77
    /**
78
     * @var ObjectManager
79
     */
80
    protected $objectManager;
81
82
    /**
83
     * @var PersistenceManager
84
     */
85
    protected $persistenceManager;
86
87
    /**
88
     * @var string
89
     */
90
    protected $baseUrl;
91
92
    /**
93
     * @var HttpClient
94
     */
95
    protected $httpClient;
96
97
    public function __construct()
98
    {
99
        parent::__construct();
100
101
        $this->configurationToUseInTestInstance['EXTENSIONS']['dlf'] = $this->getDlfConfiguration();
102
103
        if ($this->disableJsonWrappedResponse) {
104
            $this->frameworkExtensionsToLoad = array_filter($this->frameworkExtensionsToLoad, function ($ext) {
105
                return $ext !== 'Resources/Core/Functional/Extensions/json_response';
106
            });
107
        }
108
    }
109
110
    public function setUp(): void
111
    {
112
        parent::setUp();
113
114
        $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class);
115
        $this->persistenceManager = GeneralUtility::makeInstance(PersistenceManager::class);
116
117
        $this->baseUrl = 'http://web:8000/public/typo3temp/var/tests/functional-' . $this->identifier . '/';
118
        $this->httpClient = new HttpClient([
119
            'base_uri' => $this->baseUrl . 'index.php',
120
            'http_errors' => false,
121
        ]);
122
123
        $this->addSiteConfig('dlf-testing');
124
    }
125
126
    protected function getDlfConfiguration()
127
    {
128
        $dotenv = Dotenv::createImmutable('/home/runner/work/kitodo-presentation/kitodo-presentation/Build/Test/', 'test.env');
129
        $dotenv->load();
130
131
        return [
132
            'general' => [
133
                'useExternalApisForMetadata' => 0,
134
                'requiredMetadataFields' => 'document_format'
135
            ],
136
            'files' => [
137
                'fileGrpImages' => 'DEFAULT,MAX',
138
                'fileGrpThumbs' => 'THUMBS',
139
                'fileGrpDownload' => 'DOWNLOAD',
140
                'fileGrpFulltext' => 'FULLTEXT',
141
                'fileGrpAudio' => 'AUDIO'
142
            ],
143
            'solr' => [
144
                'host' => getenv('dlfTestingSolrHost'),
145
                'fields' => [
146
                    'autocomplete' => 'autocomplete',
147
                    'collection' => 'collection',
148
                    'default' => 'default',
149
                    'fulltext' => 'fulltext',
150
                    'geom' => 'geom',
151
                    'id' => 'id',
152
                    'license' => 'license',
153
                    'location' => 'location',
154
                    'page' => 'page',
155
                    'partof' => 'partof',
156
                    'pid' => 'pid',
157
                    'purl' => 'purl',
158
                    'recordId' => 'record_id',
159
                    'restrictions' => 'restrictions',
160
                    'root' => 'root',
161
                    'sid' => 'sid',
162
                    'terms' => 'terms',
163
                    'thumbnail' => 'thumbnail',
164
                    'timestamp' => 'timestamp',
165
                    'title' => 'title',
166
                    'toplevel' => 'toplevel',
167
                    'type' => 'type',
168
                    'uid' => 'uid',
169
                    'urn' => 'urn',
170
                    'volume' => 'volume'
171
                ]
172
            ]
173
        ];
174
    }
175
176
    protected function addSiteConfig($identifier)
177
    {
178
        $siteConfig = Yaml::parseFile(__DIR__ . '/../Fixtures/siteconfig.yaml');
179
        $siteConfig['base'] = $this->baseUrl;
180
        $siteConfig['languages'][0]['base'] = $this->baseUrl;
181
182
        $siteConfigPath = $this->instancePath . '/typo3conf/sites/' . $identifier;
183
        @mkdir($siteConfigPath, 0775, true);
184
        file_put_contents($siteConfigPath . '/config.yaml', Yaml::dump($siteConfig));
185
    }
186
187
    protected function initializeRepository(string $className, int $storagePid)
188
    {
189
        $repository = $this->objectManager->get($className);
190
191
        $querySettings = $this->objectManager->get(Typo3QuerySettings::class);
192
        $querySettings->setStoragePageIds([$storagePid]);
193
        $repository->setDefaultQuerySettings($querySettings);
194
195
        return $repository;
196
    }
197
198
    protected function importSolrDocuments(Solr $solr, string $path)
199
    {
200
        $jsonDocuments = json_decode(file_get_contents($path), true);
201
202
        $updateQuery = $solr->service->createUpdate();
203
        $documents = array_map(function ($jsonDoc) use ($updateQuery) {
204
            $document = $updateQuery->createDocument();
205
            foreach ($jsonDoc as $key => $value) {
206
                $document->setField($key, $value);
0 ignored issues
show
The method setField() does not exist on Solarium\Core\Query\DocumentInterface. It seems like you code against a sub-type of Solarium\Core\Query\DocumentInterface such as Solarium\Plugin\MinimumScoreFilter\Document or Solarium\QueryType\Update\Query\Document. ( Ignorable by Annotation )

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

206
                $document->/** @scrutinizer ignore-call */ 
207
                           setField($key, $value);
Loading history...
207
            }
208
            if (isset($jsonDoc['collection'])) {
209
                $document->setField('collection_faceting', $jsonDoc['collection']);
210
            }
211
            return $document;
212
        }, $jsonDocuments);
213
        $updateQuery->addDocuments($documents);
214
        $updateQuery->addCommit();
215
        $solr->service->update($updateQuery);
216
    }
217
218
    protected function initLanguageService(string $locale)
219
    {
220
        $GLOBALS['LANG'] = GeneralUtility::makeInstance(LanguageServiceFactory::class)->create($locale);
221
    }
222
223
    /**
224
     * Assert that $sub is recursively contained within $super.
225
     */
226
    protected function assertArrayMatches(array $sub, array $super, string $message = '')
227
    {
228
        self::assertEquals($sub, ArrayUtility::intersectRecursive($super, $sub), $message);
229
    }
230
}
231