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 |
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) { |
|
|
|
|
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
|
|
|
} |
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.