Skip to content

Commit

Permalink
Fix with tests and requests
Browse files Browse the repository at this point in the history
  • Loading branch information
dmongeau committed Oct 22, 2017
1 parent e40574a commit f171cdf
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 28 deletions.
35 changes: 7 additions & 28 deletions tests/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ public function testRouteLocale()
return app()->getLocale();
}]);

$response = $this->get('/fr');
$response = $this->call('GET', '/fr');
$this->assertEquals('fr', $response->getContent());

$response = $this->get('/en');
$response = $this->call('GET', '/en');
$this->assertEquals('en', $response->getContent());
}

public function testDetectFromUrlSegment()
{
Config::set('locale.detect_from_url', true);
Route::get('/fr', function () {
return app()->getLocale();
});
Expand All @@ -36,26 +37,13 @@ public function testDetectFromUrlSegment()
return app()->getLocale();
});

$response = $this->get('/fr');
$response = $this->call('GET', '/fr');
$this->assertEquals('fr', $response->getContent());

$response = $this->get('/en');
$response = $this->call('GET', '/en');
$this->assertEquals('en', $response->getContent());
}

public function testStoreInSession()
{
Config::set('locale.store_in_session', true);
app()->setLocale('en');

Route::get('/fr', ['locale' => 'fr', function () {
return app()->getLocale();
}]);

$this->get('/fr');
$this->assertEquals('fr', Session::get('locale'));
}

public function testRetrieveFromSession()
{
Config::set('locale.store_in_session', true);
Expand All @@ -65,17 +53,8 @@ public function testRetrieveFromSession()
return app()->getLocale();
}]);

$response = $this->withSession(['locale' => 'en'])
->get('/');
Session::put('locale', 'en');
$response = $this->call('GET', '/');
$this->assertEquals('en', $response->getContent());
}

public function testViewShare()
{
Config::set('app.locale', 'en');
app()->setLocale('fr');

$this->assertEquals('fr', View::shared('locale'));
$this->assertEquals(['en'], View::shared('otherLocales'));
}
}
15 changes: 15 additions & 0 deletions tests/LocaleManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,19 @@ public function testFireEvent()
$this->manager->setLocale('fr');
$this->assertTrue($obj->called);
}

public function testStoreInSession()
{
Config::set('locale.store_in_session', true);
app()->setLocale('fr');
$this->assertEquals('fr', Session::get('locale'));
}

public function testViewShare()
{
Config::set('locale.share_with_views', true);
app()->setLocale('fr');
$this->assertEquals('fr', View::shared('locale'));
$this->assertEquals(['en'], View::shared('otherLocales'));
}
}

0 comments on commit f171cdf

Please sign in to comment.