diff --git a/tests/TranslatableTest.php b/tests/TranslatableTest.php index e16943d..46a32d8 100644 --- a/tests/TranslatableTest.php +++ b/tests/TranslatableTest.php @@ -5,6 +5,7 @@ use Dimsav\Translatable\Test\Model\Country; use Dimsav\Translatable\Test\Model\CountryStrict; use Dimsav\Translatable\Test\Model\CountryWithCustomLocaleKey; +use Dimsav\Translatable\Test\Model\CountryWithCustomTranslationModel; class TranslatableTest extends TestsBase { @@ -317,6 +318,18 @@ public function test_the_locale_key_can_be_customized_per_model() $this->assertEquals($country->getLocaleKey(), 'language_id'); } + public function test_the_translation_model_can_be_customized() + { + $country = CountryWithCustomTranslationModel::create([ + 'code' => 'es', + 'name:en' => 'Spain', + 'name:de' => 'Spanien', + ]); + $this->assertTrue($country->exists()); + $this->assertEquals($country->translate('en')->name, 'Spain'); + $this->assertEquals($country->translate('de')->name, 'Spanien'); + } + public function test_it_reads_the_configuration() { $this->assertEquals(App::make('config')->get('translatable.translation_suffix'), 'Translation'); diff --git a/tests/models/CountryWithCustomLocaleKey.php b/tests/models/CountryWithCustomLocaleKey.php index dd20f44..7275c64 100644 --- a/tests/models/CountryWithCustomLocaleKey.php +++ b/tests/models/CountryWithCustomLocaleKey.php @@ -11,7 +11,6 @@ class CountryWithCustomLocaleKey extends Eloquent public $table = 'countries'; public $translatedAttributes = ['name']; - public $translationModel = 'Dimsav\Translatable\Test\Model\CountryTranslation'; /* * You can customize per model, which attribute will diff --git a/tests/models/CountryWithCustomTranslationModel.php b/tests/models/CountryWithCustomTranslationModel.php new file mode 100644 index 0000000..4d617a0 --- /dev/null +++ b/tests/models/CountryWithCustomTranslationModel.php @@ -0,0 +1,14 @@ +