示例#1
0
 public function test_whereTranslationLike_filters_by_translation_and_locale()
 {
     Country::create(['code' => 'some-code', 'name' => 'Griechenland']);
     $this->assertSame(2, Country::whereTranslationLike('name', 'Griechen%')->count());
     $result = Country::whereTranslationLike('name', '%riechenlan%', 'de')->get();
     $this->assertSame(1, $result->count());
     $this->assertSame('gr', $result->first()->code);
 }
 /**
  * @test
  */
 public function it_creates_translations_using_mass_assignment_and_locales()
 {
     $data = array('iso' => 'be', 'en' => ['name' => 'Belgium'], 'fr' => ['name' => 'Belgique']);
     $country = Country::create($data);
     $this->assertEquals('be', $country->iso);
     $this->assertEquals('Belgium', $country->translate('en')->name);
     $this->assertEquals('Belgique', $country->translate('fr')->name);
     $country = Country::whereIso('be')->first();
     $this->assertEquals('Belgium', $country->translate('en')->name);
     $this->assertEquals('Belgique', $country->translate('fr')->name);
 }
 public function test_it_creates_a_new_translation()
 {
     App::make('config')->set('translatable.fallback_locale', 'en');
     $country = Country::create(['code' => 'gr']);
     $country->getNewTranslation('en')->name = 'Greece';
     $country->save();
     $this->assertEquals($country->translate('en')->name, 'Greece');
 }