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
Pull Request — master (#137)
by joseph
60:53 queued 35:20
created

OverridesUpdateCommandTest::createOverrides()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\Tests\Large\CodeGeneration\Command;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\OverridesUpdateCommand;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\PostProcessor\FileOverrider;
7
use EdmondsCommerce\DoctrineStaticMeta\Tests\Assets\AbstractTest;
8
9
/**
10
 * @covers \EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Command\OverrideCreateCommand
11
 */
12
class OverridesUpdateCommandTest extends AbstractCommandTest
13
{
14
    public const WORK_DIR = AbstractTest::VAR_PATH . '/'
15
                            . self::TEST_TYPE_LARGE . '/OverridesUpdateCommandTest/';
16
17
    private const TEST_FILE_1 = '/src/Entity/Fields/Traits/BooleanFieldTrait.php';
18
    private const TEST_FILE_2 = '/src/Entity/Fields/Interfaces/BooleanFieldInterface.php';
19
    protected static $buildOnce = true;
20
    private $overrideFile1;
21
    private $overrideFile2;
22
23
    public function setup()
24
    {
25
        parent::setUp();
26
        if (false === self::$built) {
27
            $this->getTestCodeGenerator()
28
                 ->copyTo(self::WORK_DIR);
29
            mkdir(self::WORK_DIR . '/build/overrides', 0777, true);
30
            self::$built = true;
31
        }
32
        $this->setupCopiedWorkDir();
33
        $this->createOverrides();
34
    }
35
36
    private function createOverrides()
37
    {
38
        /**
39
         * @var FileOverrider $overrider
40
         */
41
        $overrider = $this->container->get(FileOverrider::class);
42
        $overrider->setPathToProjectRoot($this->copiedWorkDir);
0 ignored issues
show
Bug introduced by
It seems like $this->copiedWorkDir can also be of type null; however, parameter $pathToProjectRoot of EdmondsCommerce\Doctrine...:setPathToProjectRoot() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

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

42
        $overrider->setPathToProjectRoot(/** @scrutinizer ignore-type */ $this->copiedWorkDir);
Loading history...
43
        $this->overrideFile1 = $overrider->createNewOverride($this->copiedWorkDir . self::TEST_FILE_1);
44
        $this->overrideFile2 = $overrider->createNewOverride($this->copiedWorkDir . self::TEST_FILE_2);
45
    }
46
47
    /**
48
     * @test
49
     * @large
50
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
51
     */
52
    public function updateProject(): void
53
    {
54
        \ts\file_put_contents($this->overrideFile1, 'this is updated in the overrides');
55
        $command = $this->container->get(OverridesUpdateCommand::class);
56
        $tester  = $this->getCommandTester($command);
57
        $tester->execute(
58
            [
59
                '-' . OverridesUpdateCommand::OPT_PROJECT_ROOT_PATH_SHORT => $this->copiedWorkDir,
60
                '-' .
61
                OverridesUpdateCommand::OPT_OVERRIDE_ACTION_SHORT         => OverridesUpdateCommand::ACTION_TO_PROJECT,
62
            ]
63
        );
64
        $expectedOutput = <<<OUTPUT
65
+---------------------------------------------------------+
66
| /src/Entity/Fields/Interfaces/BooleanFieldInterface.php |
67
| /src/Entity/Fields/Traits/BooleanFieldTrait.php         |
68
+---------------------------------------------------------+
69
Overrides have been applied to project
70
OUTPUT;
71
        self::assertSame(trim($expectedOutput), trim($tester->getDisplay()));
72
        self::assertFileEquals($this->copiedWorkDir . self::TEST_FILE_1, $this->overrideFile1);
73
        self::assertFileEquals($this->copiedWorkDir . self::TEST_FILE_2, $this->overrideFile2);
74
    }
75
76
    /**
77
     * @test
78
     * @large
79
     * @throws \EdmondsCommerce\DoctrineStaticMeta\Exception\DoctrineStaticMetaException
80
     */
81
    public function updateOverrides(): void
82
    {
83
        \ts\file_put_contents($this->copiedWorkDir . self::TEST_FILE_1, 'this is updated in the project');
84
        $command = $this->container->get(OverridesUpdateCommand::class);
85
        $tester  = $this->getCommandTester($command);
86
        $tester->execute(
87
            [
88
                '-' . OverridesUpdateCommand::OPT_PROJECT_ROOT_PATH_SHORT => $this->copiedWorkDir,
89
                '-' .
90
                OverridesUpdateCommand::OPT_OVERRIDE_ACTION_SHORT         =>
91
                    OverridesUpdateCommand::ACTION_FROM_PROJECT,
92
            ]
93
        );
94
        $expectedOutput = <<<OUTPUT
95
+---------------------------------------------------------+
96
| /src/Entity/Fields/Interfaces/BooleanFieldInterface.php |
97
| /src/Entity/Fields/Traits/BooleanFieldTrait.php         |
98
+---------------------------------------------------------+
99
Overrides have been updated from the project
100
OUTPUT;
101
        self::assertSame(trim($expectedOutput), trim($tester->getDisplay()));
102
        self::assertFileEquals($this->overrideFile1, $this->copiedWorkDir . self::TEST_FILE_1);
103
        self::assertFileEquals($this->overrideFile2, $this->copiedWorkDir . self::TEST_FILE_2);
104
    }
105
}
106