Skip to content

Commit b7f998f

Browse files
Merge branch '2.3' into 2.7
* 2.3: [SecurityBundle] Removing test insulations for a huge perf win [Filesystem] fix tests on 2.3 [Filesystem] Recursivly widen non-executable directories
2 parents 73060e4 + bbc53dd commit b7f998f

File tree

11 files changed

+56
-71
lines changed

11 files changed

+56
-71
lines changed

src/Symfony/Bundle/SecurityBundle/Tests/Functional/AuthenticationCommencingTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ class AuthenticationCommencingTest extends WebTestCase
1616
public function testAuthenticationIsCommencingIfAccessDeniedExceptionIsWrapped()
1717
{
1818
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'config.yml'));
19-
$client->insulate();
2019

2120
$client->request('GET', '/secure-but-not-covered-by-access-control');
2221
$this->assertRedirect($client->getResponse(), '/login');

src/Symfony/Bundle/SecurityBundle/Tests/Functional/CsrfFormLoginTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class CsrfFormLoginTest extends WebTestCase
1919
public function testFormLoginAndLogoutWithCsrfTokens($config)
2020
{
2121
$client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config));
22-
$client->insulate();
2322

2423
$form = $client->request('GET', '/login')->selectButton('login')->form();
2524
$form['user_login[username]'] = 'johannes';
@@ -50,7 +49,6 @@ public function testFormLoginAndLogoutWithCsrfTokens($config)
5049
public function testFormLoginWithInvalidCsrfToken($config)
5150
{
5251
$client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config));
53-
$client->insulate();
5452

5553
$form = $client->request('GET', '/login')->selectButton('login')->form();
5654
$form['user_login[_token]'] = '';
@@ -68,7 +66,6 @@ public function testFormLoginWithInvalidCsrfToken($config)
6866
public function testFormLoginWithCustomTargetPath($config)
6967
{
7068
$client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config));
71-
$client->insulate();
7269

7370
$form = $client->request('GET', '/login')->selectButton('login')->form();
7471
$form['user_login[username]'] = 'johannes';
@@ -89,7 +86,6 @@ public function testFormLoginWithCustomTargetPath($config)
8986
public function testFormLoginRedirectsToProtectedResourceAfterLogin($config)
9087
{
9188
$client = $this->createClient(array('test_case' => 'CsrfFormLogin', 'root_config' => $config));
92-
$client->insulate();
9389

9490
$client->request('GET', '/protected-resource');
9591
$this->assertRedirect($client->getResponse(), '/login');
@@ -113,17 +109,13 @@ public function getConfigs()
113109
);
114110
}
115111

116-
protected function setUp()
112+
public static function setUpBeforeClass()
117113
{
118-
parent::setUp();
119-
120-
$this->deleteTmpDir('CsrfFormLogin');
114+
parent::deleteTmpDir('CsrfFormLogin');
121115
}
122116

123-
protected function tearDown()
117+
public static function tearDownAfterClass()
124118
{
125-
parent::tearDown();
126-
127-
$this->deleteTmpDir('CsrfFormLogin');
119+
parent::deleteTmpDir('CsrfFormLogin');
128120
}
129121
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/FirewallEntryPointTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class FirewallEntryPointTest extends WebTestCase
1818
public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
1919
{
2020
$client = $this->createClient(array('test_case' => 'FirewallEntryPoint'));
21-
$client->insulate();
2221

2322
$client->request('GET', '/secure/resource', array(), array(), array(
2423
'PHP_AUTH_USER' => 'unknown',
@@ -35,7 +34,6 @@ public function testItUsesTheConfiguredEntryPointWhenUsingUnknownCredentials()
3534
public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFormLoginAndNoCredentials()
3635
{
3736
$client = $this->createClient(array('test_case' => 'FirewallEntryPoint', 'root_config' => 'config_form_login.yml'));
38-
$client->insulate();
3937

4038
$client->request('GET', '/secure/resource');
4139

@@ -46,17 +44,13 @@ public function testItUsesTheConfiguredEntryPointFromTheExceptionListenerWithFor
4644
);
4745
}
4846

49-
protected function setUp()
47+
public static function setUpBeforeClass()
5048
{
51-
parent::setUp();
52-
53-
$this->deleteTmpDir('FirewallEntryPoint');
49+
parent::deleteTmpDir('FirewallEntryPoint');
5450
}
5551

56-
protected function tearDown()
52+
public static function tearDownAfterClass()
5753
{
58-
parent::tearDown();
59-
60-
$this->deleteTmpDir('FirewallEntryPoint');
54+
parent::deleteTmpDir('FirewallEntryPoint');
6155
}
6256
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/FormLoginTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class FormLoginTest extends WebTestCase
1919
public function testFormLogin($config)
2020
{
2121
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
22-
$client->insulate();
2322

2423
$form = $client->request('GET', '/login')->selectButton('login')->form();
2524
$form['_username'] = 'johannes';
@@ -39,7 +38,6 @@ public function testFormLogin($config)
3938
public function testFormLogout($config)
4039
{
4140
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
42-
$client->insulate();
4341

4442
$form = $client->request('GET', '/login')->selectButton('login')->form();
4543
$form['_username'] = 'johannes';
@@ -73,7 +71,6 @@ public function testFormLogout($config)
7371
public function testFormLoginWithCustomTargetPath($config)
7472
{
7573
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
76-
$client->insulate();
7774

7875
$form = $client->request('GET', '/login')->selectButton('login')->form();
7976
$form['_username'] = 'johannes';
@@ -94,7 +91,6 @@ public function testFormLoginWithCustomTargetPath($config)
9491
public function testFormLoginRedirectsToProtectedResourceAfterLogin($config)
9592
{
9693
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
97-
$client->insulate();
9894

9995
$client->request('GET', '/protected_resource');
10096
$this->assertRedirect($client->getResponse(), '/login');
@@ -118,17 +114,13 @@ public function getConfigs()
118114
);
119115
}
120116

121-
protected function setUp()
117+
public static function setUpBeforeClass()
122118
{
123-
parent::setUp();
124-
125-
$this->deleteTmpDir('StandardFormLogin');
119+
parent::deleteTmpDir('StandardFormLogin');
126120
}
127121

128-
protected function tearDown()
122+
public static function tearDownAfterClass()
129123
{
130-
parent::tearDown();
131-
132-
$this->deleteTmpDir('StandardFormLogin');
124+
parent::deleteTmpDir('StandardFormLogin');
133125
}
134126
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/LocalizedRoutesAsPathTest.php

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class LocalizedRoutesAsPathTest extends WebTestCase
1919
public function testLoginLogoutProcedure($locale)
2020
{
2121
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml'));
22-
$client->insulate();
2322

2423
$crawler = $client->request('GET', '/'.$locale.'/login');
2524
$form = $crawler->selectButton('login')->form();
@@ -41,7 +40,6 @@ public function testLoginLogoutProcedure($locale)
4140
public function testLoginFailureWithLocalizedFailurePath($locale)
4241
{
4342
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_form_failure_handler.yml'));
44-
$client->insulate();
4543

4644
$crawler = $client->request('GET', '/'.$locale.'/login');
4745
$form = $crawler->selectButton('login')->form();
@@ -58,7 +56,6 @@ public function testLoginFailureWithLocalizedFailurePath($locale)
5856
public function testAccessRestrictedResource($locale)
5957
{
6058
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes.yml'));
61-
$client->insulate();
6259

6360
$client->request('GET', '/'.$locale.'/secure/');
6461
$this->assertRedirect($client->getResponse(), '/'.$locale.'/login');
@@ -70,7 +67,6 @@ public function testAccessRestrictedResource($locale)
7067
public function testAccessRestrictedResourceWithForward($locale)
7168
{
7269
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'localized_routes_with_forward.yml'));
73-
$client->insulate();
7470

7571
$crawler = $client->request('GET', '/'.$locale.'/secure/');
7672
$this->assertCount(1, $crawler->selectButton('login'), (string) $client->getResponse());
@@ -81,17 +77,13 @@ public function getLocales()
8177
return array(array('en'), array('de'));
8278
}
8379

84-
protected function setUp()
80+
public static function setUpBeforeClass()
8581
{
86-
parent::setUp();
87-
88-
$this->deleteTmpDir('StandardFormLogin');
82+
parent::deleteTmpDir('StandardFormLogin');
8983
}
9084

91-
protected function tearDown()
85+
public static function tearDownAfterClass()
9286
{
93-
parent::tearDown();
94-
95-
$this->deleteTmpDir('StandardFormLogin');
87+
parent::deleteTmpDir('StandardFormLogin');
9688
}
9789
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SecurityRoutingIntegrationTest.php

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class SecurityRoutingIntegrationTest extends WebTestCase
1919
public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($config)
2020
{
2121
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
22-
$client->insulate();
2322
$client->request('GET', '/protected_resource');
2423

2524
$this->assertRedirect($client->getResponse(), '/login');
@@ -31,7 +30,6 @@ public function testRoutingErrorIsNotExposedForProtectedResourceWhenAnonymous($c
3130
public function testRoutingErrorIsExposedWhenNotProtected($config)
3231
{
3332
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
34-
$client->insulate();
3533
$client->request('GET', '/unprotected_resource');
3634

3735
$this->assertEquals(404, $client->getResponse()->getStatusCode(), (string) $client->getResponse());
@@ -43,7 +41,6 @@ public function testRoutingErrorIsExposedWhenNotProtected($config)
4341
public function testRoutingErrorIsNotExposedForProtectedResourceWhenLoggedInWithInsufficientRights($config)
4442
{
4543
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => $config));
46-
$client->insulate();
4744

4845
$form = $client->request('GET', '/login')->selectButton('login')->form();
4946
$form['_username'] = 'johannes';
@@ -120,17 +117,13 @@ public function getConfigs()
120117
return array(array('config.yml'), array('routes_as_path.yml'));
121118
}
122119

123-
protected function setUp()
120+
public static function setUpBeforeClass()
124121
{
125-
parent::setUp();
126-
127-
$this->deleteTmpDir('StandardFormLogin');
122+
parent::deleteTmpDir('StandardFormLogin');
128123
}
129124

130-
protected function tearDown()
125+
public static function tearDownAfterClass()
131126
{
132-
parent::tearDown();
133-
134-
$this->deleteTmpDir('StandardFormLogin');
127+
parent::deleteTmpDir('StandardFormLogin');
135128
}
136129
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/SwitchUserTest.php

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ protected function createAuthenticatedClient($username)
6262
{
6363
$client = $this->createClient(array('test_case' => 'StandardFormLogin', 'root_config' => 'switchuser.yml'));
6464
$client->followRedirects(true);
65-
$client->insulate();
6665

6766
$form = $client->request('GET', '/login')->selectButton('login')->form();
6867
$form['_username'] = $username;
@@ -72,17 +71,13 @@ protected function createAuthenticatedClient($username)
7271
return $client;
7372
}
7473

75-
protected function setUp()
74+
public static function setUpBeforeClass()
7675
{
77-
parent::setUp();
78-
79-
$this->deleteTmpDir('StandardFormLogin');
76+
parent::deleteTmpDir('StandardFormLogin');
8077
}
8178

82-
protected function tearDown()
79+
public static function tearDownAfterClass()
8380
{
84-
parent::tearDown();
85-
86-
$this->deleteTmpDir('StandardFormLogin');
81+
parent::deleteTmpDir('StandardFormLogin');
8782
}
8883
}

src/Symfony/Bundle/SecurityBundle/Tests/Functional/WebTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public static function assertRedirect($response, $location)
2323
self::assertEquals('http://localhost'.$location, $response->headers->get('Location'));
2424
}
2525

26-
protected function deleteTmpDir($testCase)
26+
protected static function deleteTmpDir($testCase)
2727
{
2828
if (!file_exists($dir = sys_get_temp_dir().'/'.Kernel::VERSION.'/'.$testCase)) {
2929
return;

src/Symfony/Bundle/SecurityBundle/Tests/Functional/app/AppKernel.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ public function __construct($testCase, $rootConfig, $environment, $debug)
6565
parent::__construct($environment, $debug);
6666
}
6767

68+
/**
69+
* {@inheritdoc}
70+
*/
71+
public function getName()
72+
{
73+
if (null === $this->name) {
74+
$this->name = parent::getName().md5($this->rootConfig);
75+
}
76+
77+
return $this->name;
78+
}
79+
6880
public function registerBundles()
6981
{
7082
if (!is_file($filename = $this->getRootDir().'/'.$this->testCase.'/bundles.php')) {

src/Symfony/Component/Filesystem/Filesystem.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,12 +192,12 @@ public function remove($files)
192192
public function chmod($files, $mode, $umask = 0000, $recursive = false)
193193
{
194194
foreach ($this->toIterator($files) as $file) {
195-
if ($recursive && is_dir($file) && !is_link($file)) {
196-
$this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
197-
}
198195
if (true !== @chmod($file, $mode & ~$umask)) {
199196
throw new IOException(sprintf('Failed to chmod file "%s".', $file), 0, null, $file);
200197
}
198+
if ($recursive && is_dir($file) && !is_link($file)) {
199+
$this->chmod(new \FilesystemIterator($file), $mode, $umask, true);
200+
}
201201
}
202202
}
203203

0 commit comments

Comments
 (0)