Passed
Branch master (ce6bb0)
by DeGracia
08:38 queued 17s
created

ManagerTests::getManager()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 20
rs 9.6
c 0
b 0
f 0
nc 1
cc 1
nop 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A ManagerTests.php$0 ➔ createFooDriver() 0 4 1
A ManagerTests.php$0 ➔ createBarDriver() 0 4 1
A ManagerTests.php$0 ➔ getDefaultDriver() 0 4 1
1
<?php
2
3
namespace DeGraciaMathieu\Manager\Tests\Templates;
4
5
use InvalidArgumentException;
6
use PHPUnit\Framework\TestCase;
7
use DeGraciaMathieu\Manager\Manager;
8
9
class ManagerTests extends TestCase
10
{
11
    /** 
12
     * @test
13
     */
14
    public function make()
15
    {
16
        $manager = $this->getManager();
17
18
        $this->assertEquals($manager->driver(), 'foo_driver');
19
        $this->assertEquals($manager->driver('foo'), 'foo_driver');
20
        $this->assertEquals($manager->driver('bar'), 'bar_driver');
21
    }
22
23
    /** 
24
     * @test
25
     */
26
    public function makeWithUnexpectedDriver()
27
    {
28
        $manager = $this->getManager();
29
30
        $this->expectException(InvalidArgumentException::class);
31
32
        $manager->driver('unexpected');
33
    }
34
35
    /**
36
     * @return Anonymous 
37
     */
38
    protected function getManager()
39
    {
40
        return new class extends Manager {
41
42
            public function createFooDriver()
43
            {
44
                return 'foo_driver';
45
            }
46
47
            public function createBarDriver()
48
            {
49
                return 'bar_driver';
50
            }            
51
52
            public function getDefaultDriver()
53
            {
54
                return 'foo';
55
            }
56
        };
57
    }
58
}
59