diff --git a/phpunit.xml b/phpunit.xml index 8ca3159..d49edee 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -16,13 +16,11 @@ ./src + + ./src/Console + - - - ./src/Console - - diff --git a/tests/DatabaseDriverTest.php b/tests/DatabaseDriverTest.php index ff6d1bc..626c6b9 100644 --- a/tests/DatabaseDriverTest.php +++ b/tests/DatabaseDriverTest.php @@ -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() { diff --git a/tests/FileDriverTest.php b/tests/FileDriverTest.php index d998ce3..20d13cc 100644 --- a/tests/FileDriverTest.php +++ b/tests/FileDriverTest.php @@ -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', + " '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() {