public function testSave()
 {
     $faker = Faker\Factory::create();
     $data = ['libelle' => str_replace('\'', '', $faker->country), 'iso' => $faker->countryCode, 'not_visible' => 0, 'is_default' => 1, 'status' => 1];
     $this->call('POST', action('Admin\\LanguageController@postEdit'), $data);
     $total = \Distilleries\Expendable\Models\Language::where('libelle', $data['libelle'])->where('iso', $data['iso'])->count();
     $this->assertEquals(1, $total);
 }
예제 #2
0
 public function testLanguageOnlyOfflineNoStatic()
 {
     $this->addContent();
     $result = \Distilleries\Expendable\Models\Language::where('is_default', 0)->onlyOffline()->get();
     foreach ($result as $lang) {
         $this->assertEquals(0, $lang->status);
     }
 }
예제 #3
0
 public function testLanguageWithOffline()
 {
     $this->addContent();
     $result = \Distilleries\Expendable\Models\Language::where('is_default', 0)->withOffline()->get();
     $count = [];
     foreach ($result as $lang) {
         $count[$lang->status] = true;
     }
     $this->assertTrue(array_key_exists(0, $count));
     $this->assertTrue(array_key_exists(1, $count));
 }
예제 #4
0
 /**
  * Handle an incoming request.
  *
  * @param \Illuminate\Http\Request $request
  * @param \Closure $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     preg_match_all('/(\\W|^)([a-z]{2})([^a-z]|$)/six', $request->server->get('HTTP_ACCEPT_LANGUAGE'), $m, PREG_PATTERN_ORDER);
     $user_langs = $m[2];
     if (!empty($user_langs[0])) {
         $total = Language::where('iso', '=', $user_langs[0])->count();
         if ($total > 0) {
             return redirect()->to('/' . $user_langs[0]);
         }
     }
     return redirect()->to('/fr');
 }