generated from spatie/package-skeleton-laravel
-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathTestCase.php
86 lines (76 loc) · 2.35 KB
/
TestCase.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php
namespace SiroDiaz\Redirection\Tests;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Routing\Router;
use Orchestra\Testbench\TestCase as Orchestra;
use SiroDiaz\Redirection\RedirectionServiceProvider;
use SiroDiaz\Redirection\RedirectRequests;
class TestCase extends Orchestra
{
/**
*/
public function setUp(): void
{
parent::setUp();
$this->getEnvironmentSetUp($this->app);
$this->setUpDatabase();
//$this->setUpMiddleware($this->app);
Factory::guessFactoryNamesUsing(
function (string $modelName) {
return 'SiroDiaz\\Redirection\\Database\\Factories\\' . class_basename($modelName) . 'Factory';
}
);
}
/**
* Define routes setup.
*
* @param Router $router
*
* @return void
*/
protected function defineRoutes($router): void
{
$router->middleware(RedirectRequests::class)->get('old-url', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('OLD-URL', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('/new/url', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('/1', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('/2', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('/3', function () {
return '';
});
$router->middleware(RedirectRequests::class)->get('/4', function () {
return '';
});
}
protected function getPackageProviders($app): array
{
return [
RedirectionServiceProvider::class,
];
}
public function getEnvironmentSetUp($app): void
{
config()->set('database.default', 'sqlite');
config()->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
]);
}
public function setUpDatabase(): void
{
$migration = include __DIR__ . '/../database/migrations/create_redirections_table.php.stub';
$migration->up();
}
}