Setting up translation module to be tested

parent 3997dc5f
<?php
namespace Modules\Translation\Tests;
use Mcamara\LaravelLocalization\LaravelLocalizationServiceProvider;
use Modules\Core\Providers\CoreServiceProvider;
use Modules\Core\Providers\SidebarServiceProvider;
use Modules\Translation\Providers\TranslationServiceProvider;
use Nwidart\Modules\LaravelModulesServiceProvider;
use Orchestra\Testbench\TestCase;
class BaseTranslationTest extends TestCase
{
public function setUp()
{
parent::setUp();
$this->resetDatabase();
}
protected function getPackageProviders($app)
{
return [
LaravelModulesServiceProvider::class,
CoreServiceProvider::class,
TranslationServiceProvider::class,
LaravelLocalizationServiceProvider::class,
SidebarServiceProvider::class,
];
}
protected function getPackageAliases($app)
{
return [];
}
protected function getEnvironmentSetUp($app)
{
$app['path.base'] = __DIR__ . '/..';
$app['config']->set('database.default', 'sqlite');
$app['config']->set('database.connections.sqlite', array(
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
));
$app['config']->set('translatable.locales', ['en', 'fr']);
}
private function resetDatabase()
{
// Makes sure the migrations table is created
$this->artisan('migrate', [
'--database' => 'sqlite',
]);
// We empty all tables
$this->artisan('migrate:reset', [
'--database' => 'sqlite',
]);
// Migrate
$this->artisan('migrate', [
'--database' => 'sqlite',
]);
}
}
<?php
namespace Modules\Translation\Tests;
use Modules\Translation\Repositories\TranslationRepository;
class EloquentTranslationRepositoryTest extends BaseTranslationTest
{
/**
* @var TranslationRepository
*/
private $translation;
public function setUp()
{
parent::setUp();
$this->translation = app(TranslationRepository::class);
}
/** @test */
public function it_is_true()
{
$this->assertTrue(true);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment