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.

ProjectVersionSlotTest   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 41
dl 0
loc 81
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getProjectVersionShouldAddProjectVersionAsSystemInformation() 0 25 1
A setUp() 0 3 1
A getProjectVersionShouldResolveCurrentVersionAndLocalizeItIfNecessary() 0 29 1
A tearDown() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace KamiYang\ProjectVersion\Tests\Unit\Backend\ToolbarItems;
5
6
/*
7
 * This file is part of the ProjectVersion project.
8
 *
9
 * It is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU General Public License as published by
11
 * the Free Software Foundation, either version 3 of the License, or
12
 * (at your option) any later version.
13
 *
14
 * For the full copyright and license information, please read
15
 * LICENSE file that was distributed with this source code.
16
 */
17
18
use KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot;
19
use KamiYang\ProjectVersion\Facade\LocalizationUtilityFacade;
20
use KamiYang\ProjectVersion\Service\ProjectVersion;
21
use KamiYang\ProjectVersion\Service\ProjectVersionService;
22
use Nimut\TestingFramework\TestCase\UnitTestCase;
23
use TYPO3\CMS\Backend\Backend\ToolbarItems\SystemInformationToolbarItem;
24
use TYPO3\CMS\Core\Utility\GeneralUtility;
25
use TYPO3\CMS\Extbase\Object\ObjectManager;
26
27
/**
28
 * Class ProjectVersionSlotTest
29
 */
30
class ProjectVersionSlotTest extends UnitTestCase
31
{
32
    /**
33
     * @var \KamiYang\ProjectVersion\Backend\ToolbarItems\ProjectVersionSlot
34
     */
35
    private $subject;
36
37
    protected function setUp()
38
    {
39
        $this->subject = new ProjectVersionSlot();
40
    }
41
42
    protected function tearDown()
43
    {
44
        GeneralUtility::purgeInstances();
45
46
        parent::tearDown();
47
    }
48
49
    /**
50
     * @test
51
     */
52
    public function getProjectVersionShouldAddProjectVersionAsSystemInformation()
53
    {
54
        $version = '9000-rc.69';
55
        $title = 'Project Version';
56
        $iconIdentifier = 'information-project-version';
57
58
        $projectVersion = new ProjectVersion();
59
        $projectVersion->setVersion($version);
60
        $projectVersion->setTitle($title);
61
62
        $systemInformationToolbarItemProphecy = $this->prophesize(SystemInformationToolbarItem::class);
63
64
        $projectVersionServiceProphecy = $this->prophesize(ProjectVersionService::class);
65
        $projectVersionServiceProphecy->getProjectVersion()->willReturn($projectVersion);
66
67
        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
68
        $objectManagerProphecy->get(ProjectVersionService::class)->willReturn($projectVersionServiceProphecy->reveal());
69
70
        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
71
        GeneralUtility::setSingletonInstance(ProjectVersionService::class, $projectVersionServiceProphecy->reveal());
72
73
        $this->subject->getProjectVersion($systemInformationToolbarItemProphecy->reveal());
74
75
        $systemInformationToolbarItemProphecy->addSystemInformation($title, $version, $iconIdentifier)
76
            ->shouldHaveBeenCalledTimes(1);
77
    }
78
79
    /**
80
     * @test
81
     */
82
    public function getProjectVersionShouldResolveCurrentVersionAndLocalizeItIfNecessary()
83
    {
84
        $initialVersionValue = 'LLL:EXT:project_version/Resources/Private/Language/Backend.xlf:toolbarItems.sysinfo.project-version.unknown';
85
        $projectVersion = new ProjectVersion();
86
        $projectVersion->setVersion($initialVersionValue);
87
        $expectedVersion = 'Unknown project version';
88
89
        $projectVersionServiceProphecy = $this->prophesize(ProjectVersionService::class);
90
        $projectVersionServiceProphecy->getProjectVersion()->willReturn($projectVersion);
91
92
        $objectManagerProphecy = $this->prophesize(ObjectManager::class);
93
        $objectManagerProphecy->get(ProjectVersionService::class)->willReturn($projectVersionServiceProphecy->reveal());
94
95
        $localizationUtilityFacadeProphecy = $this->prophesize(LocalizationUtilityFacade::class);
96
        $localizationUtilityFacadeProphecy->translate($initialVersionValue)->willReturn($expectedVersion);
97
98
        GeneralUtility::setSingletonInstance(ObjectManager::class, $objectManagerProphecy->reveal());
99
        GeneralUtility::setSingletonInstance(ProjectVersionService::class, $projectVersionServiceProphecy->reveal());
100
        GeneralUtility::addInstance(LocalizationUtilityFacade::class, $localizationUtilityFacadeProphecy->reveal());
101
102
        $systemInformationToolbarItemProphecy = $this->prophesize(SystemInformationToolbarItem::class);
103
        $actual = $this->subject->getProjectVersion($systemInformationToolbarItemProphecy->reveal());
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $actual is correct as $this->subject->getProje...ItemProphecy->reveal()) targeting KamiYang\ProjectVersion\...ot::getProjectVersion() seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
The assignment to $actual is dead and can be removed.
Loading history...
104
105
        $systemInformationToolbarItemProphecy->addSystemInformation(
106
            $projectVersion->getTitle(),
107
            $expectedVersion,
108
            $projectVersion->getIconIdentifier()
109
        )
110
            ->shouldHaveBeenCalledTimes(1);
111
    }
112
}
113