BugsnagControllerTest::testInitial()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 10
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 17
rs 9.9332
1
<?php
2
3
namespace Violet88\BugsnagModule\Tests;
4
5
use SilverStripe\Core\Injector\Injector;
6
use SilverStripe\Dev\FunctionalTest;
7
use SilverStripe\Dev\SapphireTest;
8
use Violet88\BugsnagModule\Bugsnag;
9
use Violet88\BugsnagModule\BugsnagController;
10
11
/**
12
 * @covers \Violet88\BugsnagModule\BugsnagController
13
 * @covers \Violet88\BugsnagModule\Bugsnag
14
 */
15
class BugsnagControllerTest extends SapphireTest
16
{
17
    protected static $fixture_file = 'fixtures.yml';
18
19
    public function testCommand()
20
    {
21
        Injector::nest();
22
23
        $testSnag = $this->getMockBuilder(Bugsnag::class)
24
            ->setMethods(['notifyBuild', 'setAppVersion'])
25
            ->getMock();
26
27
        $testSnag->expects($this->once())
28
            ->method('notifyBuild')
29
            ->willReturnSelf();
30
        $testSnag->expects($this->once())
31
            ->method('setAppVersion')
32
            ->willReturnSelf();
33
34
        Injector::inst()->registerService($testSnag, Bugsnag::class);
35
        BugsnagController::create()->build();
36
37
        Injector::unnest();
38
    }
39
40
    public function testInitial()
41
    {
42
        Injector::nest();
43
44
        //Making a 'mock' client so no useless errors are sent to Bugsnag.
45
        $testSnag = $this->getMockBuilder(Bugsnag::class)
46
            ->setMethods(['sendException'])
47
            ->getMock();
48
49
        Injector::inst()->registerService($testSnag, Bugsnag::class);
50
51
        $testSnag->expects($this->once())
52
            ->method('sendException')
53
            ->willReturnSelf();
54
55
        BugsnagController::create()->initial();
56
        Injector::unnest();
57
    }
58
}
59