This repository has been archived by the owner on Jun 18, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 321
/
TestsBase.php
82 lines (71 loc) · 2.35 KB
/
TestsBase.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
<?php
use Orchestra\Testbench\TestCase;
use Dimsav\Translatable\Test\Model\Country;
class TestsBase extends TestCase
{
protected $queriesCount;
protected static $db2Setup = false;
const DB_NAME = 'translatable_test';
const DB_NAME2 = 'translatable_test2';
const DB_USERNAME = 'homestead';
const DB_PASSWORD = 'secret';
protected function setUp(): void
{
parent::setUp();
$this->migrate('mysql');
$this->refreshSeedData();
}
protected function refreshSeedData()
{
$seeder = new AddFreshSeeds;
$seeder->run();
}
protected function migrate($dbConnectionName)
{
$migrationsPath = '../../../../tests/migrations';
$artisan = $this->app->make(\Illuminate\Contracts\Console\Kernel::class);
// Makes sure the migrations table is created
$artisan->call('migrate:fresh', [
'--database' => $dbConnectionName,
'--path' => $migrationsPath,
]);
}
public function testRunningMigration()
{
$country = Country::find(1);
$this->assertEquals('gr', $country->code);
}
protected function getPackageProviders($app)
{
return [
\Dimsav\Translatable\TranslatableServiceProvider::class,
];
}
protected function getEnvironmentSetUp($app)
{
$app['path.base'] = __DIR__.'/..';
$app['config']->set('database.default', 'mysql');
$app['config']->set('database.connections.mysql', [
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => static::DB_NAME,
'username' => static::DB_USERNAME,
'password' => static::DB_PASSWORD,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'strict' => false,
]);
$app['config']->set('database.connections.mysql2', [
'driver' => 'mysql',
'host' => '127.0.0.1',
'database' => static::DB_NAME2,
'username' => static::DB_USERNAME,
'password' => static::DB_PASSWORD,
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'strict' => false,
]);
$locales = ['el', 'en', 'fr', 'de', 'id', 'en-GB', 'en-US', 'de-DE', 'de-CH'];
$app['config']->set('translatable.locales', $locales);
}
}