Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
joedixon committed Apr 11, 2019
1 parent 3ec19d9 commit ee92cbb
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 5 deletions.
8 changes: 3 additions & 5 deletions phpunit.xml
Expand Up @@ -16,13 +16,11 @@
<filter>
<whitelist processUncoveredFilesFromWhitelist="true">
<directory suffix=".php">./src</directory>
<exclude>
<directory>./src/Console</directory>
</exclude>
</whitelist>
</filter>
<filter>
<blacklist>
<directory>./src/Console</directory>
</blacklist>
</filter>
<php>
<env name="APP_KEY" value="AckfSECXIvnK5r28GVIWUAxmbBSjTsmF"/>
</php>
Expand Down
27 changes: 27 additions & 0 deletions tests/DatabaseDriverTest.php
Expand Up @@ -218,6 +218,33 @@ public function it_can_add_a_vendor_namespaced_translations()
]);
}

/** @test */
public function it_can_add_a_nested_translation()
{
$this->translation->addGroupTranslation('en', 'test', 'test.nested', 'Nested!');

$this->assertEquals($this->translation->getGroupTranslationsFor('en')->toArray(), [
'test' => [
'test.nested' => 'Nested!'
],
]);
}

/** @test */
public function it_can_add_nested_vendor_namespaced_translations()
{
$this->translation->addGroupTranslation('es', 'translation_test::test', 'nested.hello', 'Hola!');

$this->assertEquals($this->translation->allTranslationsFor('es')->toArray(), [
'group' => [
'translation_test::test' => [
'nested.hello' => 'Hola!',
],
],
'single' => [],
]);
}

/** @test */
public function it_can_merge_a_namespaced_language_with_the_base_language()
{
Expand Down
36 changes: 36 additions & 0 deletions tests/FileDriverTest.php
Expand Up @@ -188,6 +188,42 @@ public function it_can_add_a_vendor_namespaced_translations()
\File::deleteDirectory(__DIR__.'/fixtures/lang/vendor');
}

/** @test */
public function it_can_add_a_nested_translation()
{
$this->translation->addGroupTranslation('en', 'test', 'test.nested', 'Nested!');

$this->assertEquals($this->translation->getGroupTranslationsFor('en')->toArray(), [
'test' => [
'hello' => 'Hello',
'test.nested' => 'Nested!',
'whats_up' => 'What\'s up!',
],
]);

file_put_contents(
app()['path.lang'].'/en/test.php',
"<?php\n\nreturn ".var_export(['hello' => 'Hello', 'whats_up' => 'What\'s up!'], true).';'.\PHP_EOL
);
}

/** @test */
public function it_can_add_nested_vendor_namespaced_translations()
{
$this->translation->addGroupTranslation('es', 'translation_test::test', 'nested.hello', 'Hola!');

$this->assertEquals($this->translation->allTranslationsFor('es')->toArray(), [
'group' => [
'translation_test::test' => [
'nested.hello' => 'Hola!',
],
],
'single' => [],
]);

\File::deleteDirectory(__DIR__.'/fixtures/lang/vendor');
}

/** @test */
public function it_can_merge_a_namespaced_language_with_the_base_language()
{
Expand Down

0 comments on commit ee92cbb

Please sign in to comment.