Fixing #138
[akelos.git] / test / unit / lib / AkActionController / _locale_detection.php
blob9a71c001cd1eb3577e9fb3d22392d6ceea1ec320
1 <?php
3 require_once(dirname(__FILE__).'/../../../fixtures/config/config.php');
5 class _AkActionController_locale_detection extends AkWebTestCase
8 function test_request_LocaleDetectionController()
10 $this->setMaximumRedirects(0);
11 $this->get(AK_TESTING_URL.'/locale_detection');
12 $this->assertResponse(200);
13 $this->assertTextMatch('Hello from LocaleDetectionController');
17 function test_Language_header_detection()
19 $this->addHeader('Accept-Language: es,en-us,en;q=0.5');
20 $this->get(AK_TESTING_URL.'/locale_detection/check_header');
21 $this->assertTextMatch('es,en-us,en;q=0.5');
24 function test_detect_default_language()
26 $this->addHeader('Accept-Language: es,en-us,en;q=0.5');
27 $this->get(AK_TESTING_URL.'/locale_detection/get_language');
28 $this->assertTextMatch('es');
31 function test_session_are_working()
33 $this->get(AK_TESTING_URL.'/locale_detection/session/1234');
34 $this->assertTextMatch('1234');
36 $this->get(AK_TESTING_URL.'/locale_detection/session/');
37 $this->assertTextMatch('1234');
40 function test_session_are_fresh_on_new_request()
42 $this->get(AK_TESTING_URL.'/locale_detection/session/');
43 $this->assertNoText('1234');
46 function test_language_change()
48 $this->assertEqual( array('en','es'), Ak::langs() );
50 $this->addHeader('Accept-Language: es,en-us,en;q=0.5');
52 $this->get(AK_TESTING_URL.'/locale_detection/get_language');
53 $this->assertTextMatch('es');
55 $this->get(AK_TESTING_URL.'/locale_detection/get_param/?param=message&message=Hello');
56 $this->assertTextMatch('Hello');
58 $this->get(AK_TESTING_URL.'/locale_detection/get_param/?param=lang&lang=en');
59 $this->assertTextMatch('en');
61 $this->get(AK_TESTING_URL.'/locale_detection/get_language/?lang=en');
62 $this->assertTextMatch('en');
64 $this->get(AK_TESTING_URL.'/locale_detection/get_language');
65 $this->assertTextMatch('en');
67 $this->get(AK_TESTING_URL.'/locale_detection/get_language/?lang=invalid');
68 $this->assertTextMatch('en');
72 function test_language_change_on_ak()
74 $this->assertEqual( array('en','es'), Ak::langs() );
76 $this->addHeader('Accept-Language: es,en-us,en;q=0.5');
78 $this->get(AK_TESTING_URL.'/locale_detection/get_language');
79 $this->assertTextMatch('es');
81 $this->get(AK_TESTING_URL.'/en/locale_detection/get_language/');
82 $this->assertTextMatch('en');
84 $this->get(AK_TESTING_URL.'/locale_detection/get_language');
85 $this->assertTextMatch('en');
89 ak_test('_AkActionController_locale_detection');