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'); |
|
|
|
|
17
|
|
|
|
18
|
|
|
$this->withFactories(__DIR__.'/factories'); |
|
|
|
|
19
|
|
|
|
20
|
|
|
\Route::group( |
21
|
|
|
[ |
22
|
|
|
'middleware' => [], |
23
|
|
|
'namespace' => 'RafflesArgentina\ResourceController', |
24
|
|
|
], function ($router) { |
25
|
|
|
$router->resource('test', 'TestController'); |
26
|
|
|
$router->resource('test2', 'TestUseSoftDeletesController'); |
27
|
|
|
$router->resource('test3', 'ApiTestController'); |
28
|
|
|
$router->resource('test4', 'ApiTestUseSoftDeletesController'); |
29
|
|
|
} |
30
|
|
|
); |
31
|
|
|
|
32
|
|
|
\View::addLocation(__DIR__.'/Resources/Views'); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** |
36
|
|
|
* Define environment setup. |
37
|
|
|
* |
38
|
|
|
* @param \Illuminate\Foundation\Application $app |
39
|
|
|
* @return void |
40
|
|
|
*/ |
41
|
|
|
protected function getEnvironmentSetUp($app) |
42
|
|
|
{ |
43
|
|
|
// Setup default database to use sqlite :memory: |
44
|
|
|
$app['config']->set('database.default', 'testbench'); |
45
|
|
|
$app['config']->set( |
46
|
|
|
'database.connections.testbench', [ |
47
|
|
|
'driver' => 'sqlite', |
48
|
|
|
'database' => ':memory:', |
49
|
|
|
'prefix' => '', |
50
|
|
|
] |
51
|
|
|
); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* Get package providers. At a minimum this is the package being tested, but also |
56
|
|
|
* would include packages upon which our package depends, e.g. Cartalyst/Sentry |
57
|
|
|
* In a normal app environment these would be added to the 'providers' array in |
58
|
|
|
* the config/app.php file. |
59
|
|
|
* |
60
|
|
|
* @param \Illuminate\Foundation\Application $app |
61
|
|
|
* |
62
|
|
|
* @return array |
63
|
|
|
*/ |
64
|
|
|
protected function getPackageProviders($app) |
|
|
|
|
65
|
|
|
{ |
66
|
|
|
return [ |
67
|
|
|
// your package service provider, |
68
|
|
|
\Orchestra\Database\ConsoleServiceProvider::class, |
69
|
|
|
]; |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* Get package aliases. In a normal app environment these would be added to |
74
|
|
|
* the 'aliases' array in the config/app.php file. If your package exposes an |
75
|
|
|
* aliased facade, you should add the alias here, along with aliases for |
76
|
|
|
* facades upon which your package depends, e.g. Cartalyst/Sentry. |
77
|
|
|
* |
78
|
|
|
* @param \Illuminate\Foundation\Application $app |
79
|
|
|
* |
80
|
|
|
* @return array |
81
|
|
|
*/ |
82
|
|
|
protected function getPackageAliases($app) |
|
|
|
|
83
|
|
|
{ |
84
|
|
|
return [ |
85
|
|
|
// |
86
|
|
|
]; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
|