public function test_it_creates_translations_using_mass_assignment_and_locales() { $data = ['code' => 'be', 'en' => ['name' => 'Belgium'], 'fr' => ['name' => 'Belgique']]; $country = Country::create($data); $this->assertEquals('be', $country->code); $this->assertEquals('Belgium', $country->translate('en')->name); $this->assertEquals('Belgique', $country->translate('fr')->name); $country = Country::whereCode('be')->first(); $this->assertEquals('Belgium', $country->translate('en')->name); $this->assertEquals('Belgique', $country->translate('fr')->name); }
public function test_passing_an_empty_array_should_not_delete_translations() { $country = Country::whereCode('gr')->with('translations')->first(); $count = count($country->translations); $country->deleteTranslations([]); $country = Country::whereCode('gr')->with('translations')->first(); $this->assertSame($count, count($country->translations)); }