Skip to content

Commit b572ab6

Browse files
committed
Move the seeders into test directory
Also renamed the DatabaseSeeder to OAuth2DatabaseSeeder. This closes #471, #467 and #435
1 parent 54cc829 commit b572ab6

12 files changed

+83
-42
lines changed

composer.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"name": "lucadegasperi/oauth2-server-laravel",
33
"description": "Laravel wrapper for the OAuth 2.0 Server package league/oauth2-server.",
44
"keywords": ["laravel", "oauth2", "oauth", "server", "api"],
5+
"license": "MIT",
56
"authors": [
67
{
78
"name": "Luca Degasperi",
@@ -29,6 +30,14 @@
2930
"psr-4": {
3031
"LucaDegasperi\\OAuth2Server\\": "src"
3132
},
33+
"classmap": [
34+
"database"
35+
]
36+
},
37+
"autoload-dev": {
38+
"psr-4": {
39+
"LucaDegasperi\\OAuth2Server\\Tests\\": "tests"
40+
},
3241
"classmap": [
3342
"database",
3443
"tests/TestCase.php",
@@ -42,6 +51,5 @@
4251
}
4352
},
4453
"minimum-stability": "dev",
45-
"prefer-stable": true,
46-
"license": "MIT"
54+
"prefer-stable": true
4755
}

database/seeds/DatabaseSeeder.php

Lines changed: 0 additions & 38 deletions
This file was deleted.

database/seeds/AccessTokensTableSeeder.php renamed to tests/Database/Seeders/AccessTokensTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class AccessTokensTableSeeder extends Seeder
1619
{

database/seeds/AuthCodesTableSeeder.php renamed to tests/Database/Seeders/AuthCodesTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class AuthCodesTableSeeder extends Seeder
1619
{

database/seeds/ClientsTableSeeder.php renamed to tests/Database/Seeders/ClientsTableSeeder.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
1213

1314
use Carbon\Carbon;
1415
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1517

1618
class ClientsTableSeeder extends Seeder
1719
{

database/seeds/GrantsTableSeeder.php renamed to tests/Database/Seeders/GrantsTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class GrantsTableSeeder extends Seeder
1619
{
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
/**
4+
* Database Seeder
5+
*
6+
* @package lucadegasperi/oauth2-server-laravel
7+
* @author Luca Degasperi <[email protected]>
8+
* @copyright Copyright (c) Luca Degasperi
9+
* @licence http://mit-license.org/
10+
* @link https://github.com/lucadegasperi/oauth2-server-laravel
11+
*/
12+
13+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
14+
15+
use Illuminate\Database\Eloquent\Model;
16+
use Illuminate\Database\Seeder;
17+
use Illuminate\Support\Facades\App;
18+
19+
class OAuth2DatabaseSeeder extends Seeder
20+
{
21+
/**
22+
* Run the database seeds.
23+
*
24+
* @return void
25+
*/
26+
public function run()
27+
{
28+
if (App::environment() === 'production') {
29+
exit('I just stopped you getting fired. Love Luca');
30+
}
31+
32+
Model::unguard();
33+
34+
$this->call(ClientsTableSeeder::class);
35+
$this->call(GrantsTableSeeder::class);
36+
$this->call(ScopesTableSeeder::class);
37+
$this->call(SessionsTableSeeder::class);
38+
$this->call(AuthCodesTableSeeder::class);
39+
$this->call(AccessTokensTableSeeder::class);
40+
$this->call(RefreshTokensTableSeeder::class);
41+
42+
Model::reguard();
43+
}
44+
}

database/seeds/RefreshTokensTableSeeder.php renamed to tests/Database/Seeders/RefreshTokensTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class RefreshTokensTableSeeder extends Seeder
1619
{

database/seeds/ScopesTableSeeder.php renamed to tests/Database/Seeders/ScopesTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class ScopesTableSeeder extends Seeder
1619
{

database/seeds/SessionsTableSeeder.php renamed to tests/Database/Seeders/SessionsTableSeeder.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,11 @@
99
* @link https://github.com/lucadegasperi/oauth2-server-laravel
1010
*/
1111

12+
namespace LucaDegasperi\OAuth2Server\Tests\Database\Seeders;
13+
1214
use Carbon\Carbon;
1315
use Illuminate\Database\Seeder;
16+
use Illuminate\Support\Facades\DB;
1417

1518
class SessionsTableSeeder extends Seeder
1619
{

0 commit comments

Comments
 (0)