|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
namespace Symfony\Bundle\SecurityBundle\Tests\Functional; |
|
|
4 |
|
|
|
5 |
class LocalizedRoutesAsPathTest extends WebTestCase |
|
|
6 |
{ |
|
|
7 |
/** |
|
|
8 |
* @dataProvider getLocales |
|
|
9 |
*/ |
|
|
10 |
public function testLoginLogoutProcedure($locale) |
|
|
11 |
{ |
|
|
12 |
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); |
|
|
13 |
$client->insulate(); |
|
|
14 |
|
|
|
15 |
$crawler = $client->request('GET', '/'.$locale.'/login'); |
|
|
16 |
$form = $crawler->selectButton('login')->form(); |
|
|
17 |
$form['_username'] = 'johannes'; |
|
|
18 |
$form['_password'] = 'test'; |
|
|
19 |
$client->submit($form); |
|
|
20 |
|
|
|
21 |
$this->assertRedirect($client->getResponse(), '/'.$locale.'/profile'); |
|
|
22 |
$this->assertEquals('Profile', $client->followRedirect()->text()); |
|
|
23 |
|
|
|
24 |
$client->request('GET', '/'.$locale.'/logout'); |
|
|
25 |
$this->assertRedirect($client->getResponse(), '/'.$locale.'/'); |
|
|
26 |
$this->assertEquals('Homepage', $client->followRedirect()->text()); |
|
|
27 |
} |
|
|
28 |
|
|
|
29 |
/** |
|
|
30 |
* @dataProvider getLocales |
|
|
31 |
*/ |
|
|
32 |
public function testAccessRestrictedResource($locale) |
|
|
33 |
{ |
|
|
34 |
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml')); |
|
|
35 |
$client->insulate(); |
|
|
36 |
|
|
|
37 |
$client->request('GET', '/'.$locale.'/secure/'); |
|
|
38 |
$this->assertRedirect($client->getResponse(), '/'.$locale.'/login'); |
|
|
39 |
} |
|
|
40 |
|
|
|
41 |
/** |
|
|
42 |
* @dataProvider getLocales |
|
|
43 |
*/ |
|
|
44 |
public function testAccessRestrictedResourceWithForward($locale) |
|
|
45 |
{ |
|
|
46 |
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml')); |
|
|
47 |
$client->insulate(); |
|
|
48 |
|
|
|
49 |
$crawler = $client->request('GET', '/'.$locale.'/secure/'); |
|
|
50 |
$this->assertEquals(1, count($crawler->selectButton('login')), (string) $client->getResponse()); |
|
|
51 |
} |
|
|
52 |
|
|
|
53 |
public function getLocales() |
|
|
54 |
{ |
|
|
55 |
return array(array('en'), array('de')); |
|
|
56 |
} |
|
|
57 |
|
|
|
58 |
protected function setUp() |
|
|
59 |
{ |
|
|
60 |
parent::setUp(); |
|
|
61 |
|
|
|
62 |
$this->deleteTmpDir('StandardFormLogin'); |
|
|
63 |
} |
|
|
64 |
|
|
|
65 |
protected function tearDown() |
|
|
66 |
{ |
|
|
67 |
parent::tearDown(); |
|
|
68 |
|
|
|
69 |
$this->deleteTmpDir('StandardFormLogin'); |
|
|
70 |
} |
|
|
71 |
} |