Completed
Pull Request — master (#35)
by Robbie
02:08 queued 45s
created

DebugBarTimeDataCollectorTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
class DebugBarTimeDataCollectorTest extends SapphireTest
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /**
6
     * @var DebugBarTimeDataCollector
7
     */
8
    protected $collector;
9
10
    public function setUp()
11
    {
12
        parent::setUp();
13
        $this->collector = new DebugBarTimeDataCollector;
14
    }
15
16
    public function testCollectorTooltip()
17
    {
18
        $result = $this->collector->getWidgets();
19
        $this->assertSame('Request duration', $result['time']['tooltip']);
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DebugBarTimeDataCollectorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
20
    }
21
22
    public function testWarning()
23
    {
24
        // Deliberately low threshold
25
        Config::inst()->update('DebugBar', 'warn_request_time_seconds', '0.00001');
26
        $result = $this->collector->getWidgets();
27
28
        $this->assertSame('danger', $result['time']['warn']);
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DebugBarTimeDataCollectorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
        $this->assertSame('0.00001', $result['time']['warn_threshold_seconds']);
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DebugBarTimeDataCollectorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
30
31
        // Deliberately high threshold and low ratio
32
        Config::inst()->update('DebugBar', 'warn_request_time_seconds', '100');
33
        Config::inst()->update('DebugBar', 'warn_warning_ratio', '0.000000001');
34
        $result = $this->collector->getWidgets();
35
36
        $this->assertSame('warning', $result['time']['warn']);
0 ignored issues
show
Bug introduced by
The method assertSame() does not seem to exist on object<DebugBarTimeDataCollectorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
37
    }
38
39
    public function testWarningCanBeDisabled()
40
    {
41
        Config::inst()->update('DebugBar', 'warn_request_time_seconds', false);
42
        $result = $this->collector->getWidgets();
43
        $this->assertFalse($result['time']['warn']);
0 ignored issues
show
Bug introduced by
The method assertFalse() does not seem to exist on object<DebugBarTimeDataCollectorTest>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
44
    }
45
}
46