AbstractTestCase::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 14
rs 9.4285
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/**
3
 * This file is part of Friends.
4
 *
5
 * (c) Christopher Lass <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
use Arubacao\Friends\FriendsServiceProvider;
12
use GrahamCampbell\TestBench\AbstractPackageTestCase;
13
14
abstract class AbstractTestCase extends AbstractPackageTestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
15
{
16
    /**
17
     * Get the service provider class.
18
     *
19
     * @param \Illuminate\Contracts\Foundation\Application $app
20
     *
21
     * @return string
22
     */
23
    protected function getServiceProviderClass($app)
24
    {
25
        return FriendsServiceProvider::class;
26
    }
27
    /**
28
     * Define environment setup.
29
     *
30
     * @param  \Illuminate\Foundation\Application  $app
31
     *
32
     * @return void
33
     */
34
    protected function getEnvironmentSetUp($app)
35
    {
36
        parent::getEnvironmentSetUp($app);
37
        
38
        $app['config']->set('friends.user_model', User::class);
39
40
//        \Schema::create('users', function ($table) {
0 ignored issues
show
Unused Code Comprehensibility introduced by
64% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
//            $table->increments('id');
42
//            $table->string('name');
43
//            $table->timestamps();
44
//        });
45
    }
46
47
    /**
48
     * Setup the test environment.
49
     */
50
    public function setUp()
51
    {
52
        parent::setUp();
53
54
        $this->artisan('migrate', [
55
            '--realpath' => realpath(__DIR__.'/database/migrations'),
56
        ]);
57
58
        $this->artisan('migrate', [
59
            '--realpath' => realpath(__DIR__.'/../src/database/migrations'),
60
        ]);
61
62
        $this->withFactories(realpath(__DIR__.'/database/factories'));
63
    }
64
65
    /**
66
     * Call protected/private method of a class.
67
     *
68
     * @param object &$object    Instantiated object that we will run method on.
69
     * @param string $methodName Method name to call
70
     * @param array  $parameters Array of parameters to pass into method.
71
     *
72
     * @return mixed Method return.
73
     */
74
    public function invokeMethod(&$object, $methodName, array $parameters = array())
75
    {
76
        $reflection = new \ReflectionClass(get_class($object));
77
        $method = $reflection->getMethod($methodName);
78
        $method->setAccessible(true);
79
80
        return $method->invokeArgs($object, $parameters);
81
    }
82
}