OpenInEditorTest::getPackageProviders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace MathieuTu\LaravelOpenInEditor\Tests;
4
5
use MathieuTu\LaravelOpenInEditor\ServiceProvider;
6
use Orchestra\Testbench\TestCase;
7
8
class OpenInEditorTest extends TestCase
9
{
10
    /**
11
     * @dataProvider getEditors
12
     */
13
    public function testItRedirectToEditorWhenRouteIsCalled($editor, $url)
14
    {
15
        config(['app.editor' => $editor]);
16
        $this->get('__open-in-editor?file=foo.bar&line=134')->assertRedirect($url);
17
    }
18
19
    public function testItRedirectToEditorWithoutLine()
20
    {
21
        config(['app.editor' => 'phpstorm']);
22
        $this->get('__open-in-editor?file=foo.bar')->assertRedirect('phpstorm://open?file=foo.bar&line=0');
23
    }
24
25
    public function getEditors()
26
    {
27
        return [
28
            ['sublime', 'subl://open?url=file://foo.bar&line=134'],
29
            ['textmate', 'txmt://open?url=file://foo.bar&line=134'],
30
            ['emacs', 'emacs://open?url=file://foo.bar&line=134'],
31
            ['macvim', 'mvim://open/?url=file://foo.bar&line=134'],
32
            ['phpstorm', 'phpstorm://open?file=foo.bar&line=134'],
33
            ['idea', 'idea://open?file=foo.bar&line=134'],
34
            ['vscode', 'vscode://file/foo.bar:134'],
35
        ];
36
    }
37
38
    protected function getEnvironmentSetUp($app)
39
    {
40
        $app['config']->set('app.debug', true);
41
    }
42
43
    protected function getPackageProviders($app)
44
    {
45
        return [ServiceProvider::class];
46
    }
47
}
48