Passed
Push — master ( 4573fb...494e83 )
by Mario
02:34
created

BaseTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 74
Duplicated Lines 0 %

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getPackageAliases() 0 3 1
A setUp() 0 19 1
A getEnvironmentSetUp() 0 8 1
A getPackageProviders() 0 5 1
1
<?php
2
3
namespace RafflesArgentina\ResourceController;
4
5
trait BaseTest
6
{
7
    /**
8
     * Setup the test environment.
9
     */
10
    public function setUp()
11
    {
12
        parent::setUp();
13
14
        gc_disable();
15
16
        $this->loadMigrationsFrom(__DIR__.'/database/migrations');
0 ignored issues
show
Bug introduced by
It seems like loadMigrationsFrom() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

16
        $this->/** @scrutinizer ignore-call */ 
17
               loadMigrationsFrom(__DIR__.'/database/migrations');
Loading history...
17
18
        $this->withFactories(__DIR__.'/factories');
0 ignored issues
show
Bug introduced by
It seems like withFactories() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

18
        $this->/** @scrutinizer ignore-call */ 
19
               withFactories(__DIR__.'/factories');
Loading history...
19
20
        \Route::group([
21
            'middleware' => [],
22
            'namespace'  => 'RafflesArgentina\ResourceController',
23
        ], function ($router) {
0 ignored issues
show
Unused Code introduced by
The call to Illuminate\Support\Facades\Route::group() has too many arguments starting with function(...) { /* ... */ }. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        \Route::/** @scrutinizer ignore-call */ 
24
                group([

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
24
            $router->resource('test', 'TestController');
25
            $router->resource('test2', 'TestUseSoftDeletesController');
26
        });
27
28
        \View::addLocation(__DIR__.'/Resources/Views');
29
    }
30
31
    /**
32
     * Define environment setup.
33
     *
34
     * @param  \Illuminate\Foundation\Application  $app
35
     * @return void
36
     */
37
    protected function getEnvironmentSetUp($app)
38
    {
39
        // Setup default database to use sqlite :memory:
40
        $app['config']->set('database.default', 'testbench');
41
        $app['config']->set('database.connections.testbench', [
42
            'driver'   => 'sqlite',
43
            'database' => ':memory:',
44
            'prefix'   => '',
45
        ]);
46
    }
47
48
    /**
49
     * Get package providers.  At a minimum this is the package being tested, but also
50
     * would include packages upon which our package depends, e.g. Cartalyst/Sentry
51
     * In a normal app environment these would be added to the 'providers' array in
52
     * the config/app.php file.
53
     *
54
     * @param  \Illuminate\Foundation\Application  $app
55
     *
56
     * @return array
57
     */
58
    protected function getPackageProviders($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

58
    protected function getPackageProviders(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
59
    {
60
        return [
61
            // your package service provider,
62
            \Orchestra\Database\ConsoleServiceProvider::class,
63
        ];
64
    }
65
66
    /**
67
     * Get package aliases.  In a normal app environment these would be added to
68
     * the 'aliases' array in the config/app.php file.  If your package exposes an
69
     * aliased facade, you should add the alias here, along with aliases for
70
     * facades upon which your package depends, e.g. Cartalyst/Sentry.
71
     *
72
     * @param  \Illuminate\Foundation\Application  $app
73
     *
74
     * @return array
75
     */
76
    protected function getPackageAliases($app)
0 ignored issues
show
Unused Code introduced by
The parameter $app is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

76
    protected function getPackageAliases(/** @scrutinizer ignore-unused */ $app)

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
77
    {
78
        return [
79
            //
80
        ];
81
    }
82
}
83