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.

TokenRepositoryTest::deleteExpiredTokens()   A
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 43
Code Lines 27

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 27
c 2
b 0
f 0
nc 8
nop 0
dl 0
loc 43
rs 9.1768
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\Repository;
14
15
use Kitodo\Dlf\Domain\Repository\TokenRepository;
16
use Kitodo\Dlf\Tests\Functional\FunctionalTestCase;
17
18
class TokenRepositoryTest extends FunctionalTestCase
19
{
20
    /**
21
     * @var TokenRepository
22
     */
23
    protected $tokenRepository;
24
25
    public function setUp(): void
26
    {
27
        parent::setUp();
28
29
        $this->tokenRepository = $this->initializeRepository(
30
            TokenRepository::class,
31
            20000
32
        );
33
    }
34
35
    public function tearDown(): void
36
    {
37
        parent::tearDown();
38
39
        unlink(__DIR__ . '/../../Fixtures/Repository/tokenTemp.csv');
40
    }
41
42
    /**
43
     * @test
44
     * @group delete
45
     */
46
    public function deleteExpiredTokens(): void
47
    {
48
        $inputCsvFile = __DIR__ . '/../../Fixtures/Repository/token.csv';
49
        $outputCsvFile = __DIR__ . '/../../Fixtures/Repository/tokenTemp.csv';
50
51
        $inputCsvData = file_get_contents($inputCsvFile);
52
        $csvData = str_getcsv($inputCsvData, "\n");
53
54
        $expireTime = 3600;
55
        $i = 1;
56
57
        foreach ($csvData as $key => &$row) {
58
            if ($key > 1) {
59
                $columns = str_getcsv($row, ",");
60
                if ($i % 2 == 0) {
61
                    $columns[3] = time() - $expireTime - rand(10, 3600);
62
                } else {
63
                    $columns[3] = time() - $expireTime + rand(10, 3600);
64
                }
65
                $row = implode(",", $columns);
66
                $i++;
67
            }
68
        }
69
70
        $outputCsvData = implode("\n", $csvData);
71
        file_put_contents($outputCsvFile, $outputCsvData);
72
73
        $this->importCSVDataSet($outputCsvFile);
74
        $this->tokenRepository->deleteExpiredTokens($expireTime);
75
76
        $this->persistenceManager->persistAll();
77
78
        $tokens = $this->tokenRepository->findAll();
79
80
        self::assertEquals(2, $tokens->count());
81
82
        $tokenUids = [];
83
        foreach ($tokens as $token) {
84
            $tokenUids[$token->getUid()] = $token;
85
        }
86
87
        self::assertArrayHasKey('101', $tokenUids);
88
        self::assertArrayHasKey('103', $tokenUids);
89
    }
90
}
91