-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathTestCase.php
59 lines (50 loc) · 1.6 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
<?php
namespace BeyondCode\Comments\Tests;
use BeyondCode\Comments\CommentsServiceProvider;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Foundation\Auth\User;
abstract class TestCase extends \Orchestra\Testbench\TestCase
{
protected function setUp(): void
{
parent::setUp();
$this->loadLaravelMigrations(['--database' => 'sqlite']);
$this->setUpDatabase();
$this->createUser();
}
protected function getPackageProviders($app)
{
return [
CommentsServiceProvider::class,
];
}
protected function getEnvironmentSetUp($app)
{
$app['config']->set('auth.providers.users.model', User::class);
$app['config']->set('database.default', 'sqlite');
$app['config']->set('database.connections.sqlite', [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
]);
$app['config']->set('app.key', 'base64:6Cu/ozj4gPtIjmXjr8EdVnGFNsdRqZfHfVjQkmTlg4Y=');
}
protected function setUpDatabase()
{
include_once __DIR__.'/../database/migrations/create_comments_table.php.stub';
(new \CreateCommentsTable)->up();
$this->app['db']->connection()->getSchemaBuilder()->create('posts', function (Blueprint $table) {
$table->increments('id');
$table->string('title');
$table->timestamps();
});
}
protected function createUser()
{
User::forceCreate([
'name' => 'User',
'email' => '[email protected]',
'password' => 'test',
]);
}
}