test groups refactoring

This commit is contained in:
Peter Papp
2021-07-18 16:53:12 +02:00
parent 18150cd920
commit a1778eab52
83 changed files with 1482 additions and 1421 deletions

View File

@@ -0,0 +1,92 @@
<?php
namespace Tests\Domain\Languages;
use Domain\Settings\Models\Language;
use Domain\Settings\Models\Setting;
use Domain\Settings\Models\User;
use Domain\SetupWizard\Services\SetupService;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class TranslationsAccessTest extends TestCase
{
protected $setup;
public function __construct()
{
parent::__construct();
$this->setup = app()->make(SetupService::class);
}
/**
* @test
*/
public function it_get_language_translations_for_frontend()
{
$this->setup->seed_default_language();
$this->getJson("/translations/en")
->assertStatus(200)
->assertJsonFragment([
"actions.close" => "Close",
]);
}
/**
* @test
*/
public function it_get_custom_translations_from_file_config()
{
$this->setup->seed_default_language();
$this->assertDatabaseHas('language_translations', [
'key' => 'custom',
'value' => 'translation',
'lang' => 'en',
]);
}
/**
* @test
*/
public function it_get_translated_string_from_t_helper_function()
{
$this->setup->seed_default_language();
Language::first()
->languageTranslations()
->forceCreate([
"key" => "test",
"value" => "Hi, my name is :name :surname",
"lang" => "en",
]);
$this->assertEquals(
'Close',
__t('actions.close')
);
$this->assertEquals(
'🙋 John share some files with you. Look at it!',
__t('shared_link_email_subject', ['user' => 'John'])
);
$this->assertEquals(
'Hi, my name is John Doe',
__t('test', ['name' => 'John', 'surname' => 'Doe'])
);
}
/**
* @test
*/
public function it_get_translated_string_from_t_helper_without_database_connection()
{
$this->assertEquals(
__t('actions.close'),
'Close'
);
}
}