Test Failed
Push — stable ( 9139cf...ac521b )
by Nuno
02:03
created

HelpersTest::config_path_helper_function()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 12
rs 9.4285

1 Method

Rating   Name   Duplication   Size   Complexity  
A HelpersTest::app_path_helper() 0 6 1
1
<?php
2
3
namespace Tests\Integration;
4
5
use Tests\TestCase;
6
use LaravelZero\Framework\Container;
7
8
class HelpersTest extends TestCase
9
{
10
    /** @test */
11
    public function app_helper(): void
12
    {
13
        $this->assertSame(app(), Container::getInstance());
14
15
        Container::getInstance()->bind('foo', function () {
16
            return 'bar';
17
        });
18
19
        $this->assertEquals(app('foo'), 'bar');
20
    }
21
22
    /** @test */
23
    public function app_path_helper(): void
24
    {
25
        $this->assertSame(app_path(), app('path'));
26
27
        $this->assertEquals(app_path('foo'), app('path').DIRECTORY_SEPARATOR.'foo');
28
    }
29
30
    /** @test */
31
    public function config_helper(): void
32
    {
33
        $this->assertSame(config(), app('config'));
34
35
        config(['foo' => 'bar']);
36
37
        $this->assertEquals(app('config')->get('foo'), 'bar');
38
39
        $this->assertEquals(app('config')->get('foo2', 2), 2);
40
    }
41
42
    /** @test */
43
    public function event_helper(): void
44
    {
45
        // @todo ...
46
    }
47
48
    /** @test */
49
    public function base_path_helper(): void
50
    {
51
        $this->assertEquals(BASE_PATH, base_path());
52
        $this->assertEquals(
53
            BASE_PATH.DIRECTORY_SEPARATOR.'some'.DIRECTORY_SEPARATOR.'directory',
54
            base_path('some'.DIRECTORY_SEPARATOR.'directory')
55
        );
56
    }
57
58
    /** @test */
59
    public function config_path_helper(): void
60
    {
61
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'config', config_path());
62
        $this->assertEquals(
63
            BASE_PATH.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'vendor',
64
            config_path('vendor')
65
        );
66
        $this->assertEquals(
67
            BASE_PATH.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'custom.php',
68
            config_path('custom.php')
69
        );
70
    }
71
72
    /** @test */
73 View Code Duplication
    public function database_path_helper(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
74
    {
75
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'database', database_path());
76
        $this->assertEquals(
77
            BASE_PATH.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'seeds',
78
            database_path('seeds')
79
        );
80
        $this->assertEquals(
81
            BASE_PATH.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php',
82
            database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php')
83
        );
84
    }
85
86
    /** @test */
87
    public function resource_path_helper(): void
88
    {
89
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'resources', resource_path());
90
        $this->assertEquals(
91
            BASE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'js',
92
            resource_path('assets'.DIRECTORY_SEPARATOR.'js')
93
        );
94
        $this->assertEquals(
95
            BASE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'app.php',
96
            resource_path('assets'.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'app.php')
97
        );
98
    }
99
100
    /** @test */
101 View Code Duplication
    public function storage_path_helper(): void
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
102
    {
103
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'storage', storage_path());
104
        $this->assertEquals(
105
            BASE_PATH.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'logs',
106
            storage_path('logs')
107
        );
108
        $this->assertEquals(
109
            BASE_PATH.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR.'laravel.log',
110
            storage_path('logs'.DIRECTORY_SEPARATOR.'laravel.log')
111
        );
112
    }
113
}
114