8000 minor #11191 [Tests] fix tests due to recent changes in PHP's behavio… · symfony/symfony@f45f2df · GitHub
[go: up one dir, main page]

Skip to content

Commit f45f2df

Browse files
committed
minor #11191 [Tests] fix tests due to recent changes in PHP's behavior (xabbuh)
This PR was merged into the 2.4 branch. Discussion ---------- [Tests] fix tests due to recent changes in PHP's behavior | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | yes | Deprecations? | no | Tests pass? | yes | Fixed tickets | #11176 | License | MIT | Doc PR | The drawback of this solution is that the pretty printed string produced by ``json_encode()`` isn't validated anymore. Instead, the tests only ensures that the represented object structure is as expected. I guess that's fair enough since the goal of the test is not to test PHP's pretty printing feature. Commits ------- bc8042d don't disable constructor calls to mockups of classes that extend internal PHP classes f4a3c7a special handling for the JsonDescriptor to work around changes in PHP's JSON pretty printer
2 parents f2bdc22 + bc8042d commit f45f2df

File tree

6 files changed

+16
-11
lines changed

6 files changed

+16
-11
lines changed

src/Symfony/Bundle/FrameworkBundle/Tests/Console/Descriptor/AbstractDescriptorTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,12 @@ private function assertDescription($expectedDescription, $describedObject, array
9595
$options['raw_output'] = true;
9696
$output = new BufferedOutput(BufferedOutput::VERBOSITY_NORMAL, true);
9797
$this->getDescriptor()->describe($output, $describedObject, $options);
98-
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
98+
99+
if ('json' === $this->getFormat()) {
100+
$this->assertEquals(json_decode($expectedDescription), json_decode($output->fetch()));
101+
} else {
102+
$this->assertEquals(trim($expectedDescription), trim(str_replace(PHP_EOL, "\n", $output->fetch())));
10000
103+
}
99104
}
100105

101106
private function getDescriptionTestData(array $objects)

src/Symfony/Component/Security/Core/Tests/Authentication/AuthenticationProviderManagerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected function getAuthenticationProvider($supports, $token = null, $exceptio
129129
} elseif (null !== $exception) {
130130
$provider->expects($this->once())
131131
->method('authenticate')
132-
->will($this->throwException($this->getMock($exception, null, array(), '', false)))
132+
->will($this->throwException($this->getMock($exception, null, array(), '')))
133133
;
134134
}
135135

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/DaoAuthenticationProviderTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function testRetrieveUserWhenUsernameIsNotFound()
3737
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
3838
$userProvider->expects($this->once())
3939
->method('loadUserByUsername')
40-
->will($this->throwException($this->getMock('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', null, array(), '', false)))
40+
->will($this->throwException($this->getMock('Symfony\\Component\\Security\\Core\\Exception\\UsernameNotFoundException', null, array(), '')))
4141
;
4242

4343
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));
@@ -55,7 +55,7 @@ public function testRetrieveUserWhenAnExceptionOccurs()
5555
$userProvider = $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserProviderInterface');
5656
$userProvider->expects($this->once())
5757
->method('loadUserByUsername')
58-
->will($this->throwException($this->getMock('RuntimeException', null, array(), '', false)))
58+
->will($this->throwException($this->getMock('RuntimeException', null, array(), '')))
5959
;
6060

6161
$provider = new DaoAuthenticationProvider($userProvider, $this->getMock('Symfony\\Component\\Security\\Core\\User\\UserCheckerInterface'), 'key', $this->getMock('Symfony\\Component\\Security\\Core\\Encoder\\EncoderFactoryInterface'));

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/PreAuthenticatedAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public function testAuthenticateWhenUserCheckerThrowsException()
7979
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
8080
$userChecker->expects($this->once())
8181
->method('checkPostAuth')
82-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\LockedException', null, array(), '', false)))
82+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\LockedException', null, array(), '')))
8383
;
8484

8585
$provider = $this->getProvider($user, $userChecker);

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/RememberMeAuthenticationProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function testAuthenticateWhenPostChecksFails()
5252
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
5353
$userChecker->expects($this->once())
5454
->method('checkPostAuth')
55-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false)))
55+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '')))
5656
;
5757

5858
$provider = $this->getProvider($userChecker);

src/Symfony/Component/Security/Core/Tests/Authentication/Provider/UserAuthenticationProviderTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testAuthenticateWhenUsernameIsNotFound()
4141
$provider = $this->getProvider(false, false);
4242
$provider->expects($this->once())
4343
->method('retrieveUser')
44-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
44+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '')))
4545
;
4646

4747
$provider->authenticate($this->getSupportedToken());
@@ -55,7 +55,7 @@ public function testAuthenticateWhenUsernameIsNotFoundAndHideIsTrue()
5555
$provider = $this->getProvider(false, true);
5656
$provider->expects($this->once())
5757
->method('retrieveUser')
58-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '', false)))
58+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\UsernameNotFoundException', null, array(), '')))
5959
;
6060

6161
$provider->authenticate($this->getSupportedToken());
@@ -83,7 +83,7 @@ public function testAuthenticateWhenPreChecksFails()
8383
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
8484
$userChecker->expects($this->once())
8585
->method('checkPreAuth')
86-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '', false)))
86+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\CredentialsExpiredException', null, array(), '')))
8787
;
8888

8989
$provider = $this->getProvider($userChecker);
@@ -103,7 +103,7 @@ public function testAuthenticateWhenPostChecksFails()
103103
$userChecker = $this->getMock('Symfony\Component\Security\Core\User\UserCheckerInterface');
104104
$userChecker->expects($this->once())
105105
->method('checkPostAuth')
106-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '', false)))
106+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\AccountExpiredException', null, array(), '')))
107107
;
108108

109109
$provider = $this->getProvider($userChecker);
@@ -128,7 +128,7 @@ public function testAuthenticateWhenPostCheckAuthenticationFails()
128128
;
129129
$provider->expects($this->once())
130130
->method('checkAuthentication')
131-
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '', false)))
131+
->will($this->throwException($this->getMock('Symfony\Component\Security\Core\Exception\BadCredentialsException', null, array(), '')))
132132
;
133133

134134
$provider->authenticate($this->getSupportedToken());

0 commit comments

Comments
 (0)
0