Completed
Push — master ( e28c79...14b414 )
by Avtandil
02:36
created

ServiceProviderTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 47
rs 10
wmc 5
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A check_if_commands_registered() 0 18 2
A check_if_request_has_macros() 0 7 1
A check_blade_directives() 0 12 2
1
<?php
2
declare(strict_types=1);
3
4
namespace Tests\Unit;
5
6
use Blade;
7
use Illuminate\Contracts\Console\Kernel;
8
use Illuminate\Http\Request;
9
10
class ServiceProviderTest extends TestCase
11
{
12
13
    /** @test */
14
    public function check_if_commands_registered()
15
    {
16
        $commands = [
17
            'command.lodash.clear-all'     => 'clear-all',
18
            'command.lodash.db.clear'      => 'db:clear',
19
            'command.lodash.db.dump'       => 'db:dump',
20
            'command.lodash.db.restore'    => 'db:restore',
21
            'command.lodash.log.clear'     => 'log:clear',
22
            'command.lodash.user.add'      => 'user:add',
23
            'command.lodash.user.password' => 'user:password',
24
        ];
25
26
        $registered = $this->app[Kernel::class]->all();
27
        foreach ($commands as $command => $name) {
28
            $this->assertTrue($this->app->bound($command));
29
            $this->assertContains($name, array_keys($registered));
30
        }
31
    }
32
33
    /** @test */
34
    public function check_if_request_has_macros()
35
    {
36
        $this->assertTrue(Request::hasMacro('getInt'));
37
        $this->assertTrue(Request::hasMacro('getBool'));
38
        $this->assertTrue(Request::hasMacro('getFloat'));
39
        $this->assertTrue(Request::hasMacro('getString'));
40
    }
41
42
    /** @test */
43
    public function check_blade_directives()
44
    {
45
        $directives = [
46
            'datetime',
47
            'plural',
48
        ];
49
50
        $registered = Blade::getCustomDirectives();
51
        foreach ($directives as $directive) {
52
            $this->assertContains($directive, array_keys($registered));
53
        }
54
    }
55
56
}
57