LeftAndMainExtensionTest::testInit()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LeKoala\DebugBar\Test\Extension;
4
5
use LeKoala\DebugBar\DebugBar;
6
use LeKoala\DebugBar\Extension\LeftAndMainExtension;
7
use SilverStripe\Dev\SapphireTest;
8
9
class LeftAndMainExtensionTest extends SapphireTest
10
{
11
    /**
12
     * @var LeftAndMainExtension
13
     */
14
    protected $extension;
15
16
    /**
17
     * @var DebugBar\DataCollector\TimeDataCollector
0 ignored issues
show
Bug introduced by
The type LeKoala\DebugBar\DebugBa...ector\TimeDataCollector was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
18
     */
19
    protected $timeCollector;
20
21
    public function setUp(): void
22
    {
23
        parent::setUp();
24
25
        $this->extension = new LeftAndMainExtension;
26
        DebugBar::initDebugBar();
27
        $this->timeCollector = DebugBar::getDebugBar()->getCollector('time');
0 ignored issues
show
Documentation Bug introduced by
It seems like LeKoala\DebugBar\DebugBa...)->getCollector('time') of type DebugBar\DataCollector\DataCollectorInterface is incompatible with the declared type LeKoala\DebugBar\DebugBa...ector\TimeDataCollector of property $timeCollector.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
28
    }
29
30
    public function tearDown(): void
31
    {
32
        DebugBar::clearDebugBar();
33
34
        parent::tearDown();
35
    }
36
37
    public function testAccessedCms()
38
    {
39
        $this->extension->accessedCMS();
40
        $this->assertFalse($this->timeCollector->hasStartedMeasure('init'));
41
        $this->assertTrue($this->timeCollector->hasStartedMeasure('cms_accessed'));
42
    }
43
44
    public function testInit()
45
    {
46
        $this->extension->init();
47
        $this->assertFalse($this->timeCollector->hasStartedMeasure('cms_accessed'));
48
        $this->assertTrue($this->timeCollector->hasStartedMeasure('cms_init'));
49
    }
50
}
51