Test Failed
Push — stable ( ba7d8d...8f8e37 )
by Nuno
01:57
created

HelpersTest::event_helper()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
rs 9.4285
1
<?php
2
3
namespace Tests;
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
        $this->assertTrue(true);
47
    }
48
49
    /** @test */
50
    public function base_path_helper(): void
51
    {
52
        $this->assertEquals(BASE_PATH, base_path());
53
        $this->assertEquals(
54
            BASE_PATH.DIRECTORY_SEPARATOR.'some'.DIRECTORY_SEPARATOR.'directory',
55
            base_path('some'.DIRECTORY_SEPARATOR.'directory')
56
        );
57
    }
58
59
    /** @test */
60
    public function config_path_helper(): void
61
    {
62
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'config', config_path());
63
        $this->assertEquals(
64
            BASE_PATH.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'vendor',
65
            config_path('vendor')
66
        );
67
        $this->assertEquals(
68
            BASE_PATH.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'custom.php',
69
            config_path('custom.php')
70
        );
71
    }
72
73
    /** @test */
74 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...
75
    {
76
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'database', database_path());
77
        $this->assertEquals(
78
            BASE_PATH.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'seeds',
79
            database_path('seeds')
80
        );
81
        $this->assertEquals(
82
            BASE_PATH.DIRECTORY_SEPARATOR.'database'.DIRECTORY_SEPARATOR.'seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php',
83
            database_path('seeds'.DIRECTORY_SEPARATOR.'DatabaseSeeder.php')
84
        );
85
    }
86
87
    /** @test */
88
    public function resource_path_helper(): void
89
    {
90
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'resources', resource_path());
91
        $this->assertEquals(
92
            BASE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'js',
93
            resource_path('assets'.DIRECTORY_SEPARATOR.'js')
94
        );
95
        $this->assertEquals(
96
            BASE_PATH.DIRECTORY_SEPARATOR.'resources'.DIRECTORY_SEPARATOR.'assets'.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'app.php',
97
            resource_path('assets'.DIRECTORY_SEPARATOR.'js'.DIRECTORY_SEPARATOR.'app.php')
98
        );
99
    }
100
101
    /** @test */
102 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...
103
    {
104
        $this->assertEquals(BASE_PATH.DIRECTORY_SEPARATOR.'storage', storage_path());
105
        $this->assertEquals(
106
            BASE_PATH.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'logs',
107
            storage_path('logs')
108
        );
109
        $this->assertEquals(
110
            BASE_PATH.DIRECTORY_SEPARATOR.'storage'.DIRECTORY_SEPARATOR.'logs'.DIRECTORY_SEPARATOR.'laravel.log',
111
            storage_path('logs'.DIRECTORY_SEPARATOR.'laravel.log')
112
        );
113
    }
114
}
115