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

ManagerTests   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
dl 0
loc 50
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A hp$0 ➔ createFooDriver() 0 4 1
A hp$0 ➔ createBarDriver() 0 4 1
A hp$0 ➔ getDefaultDriver() 0 4 1
A make() 0 8 1
A makeWithUnexpectedDriver() 0 8 1
A getManager() 0 20 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