-
Notifications
You must be signed in to change notification settings - Fork 1
Unit test for the PasswordGrantExtension #28
base: v2.2
Are you sure you want to change the base?
Conversation
| */ | ||
| class PasswordGrantExtensionTest extends \PHPUnit_Framework_TestCase | ||
| { | ||
| public function testConfigureRequestParameters() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
phpdoc
|
|
||
| $actualDefinedOptions = $optionsResolver->getRequiredOptions(); | ||
| $expectedDefinedOptions = ['password', 'username']; | ||
| $this->assertEquals($expectedDefinedOptions, $actualDefinedOptions, '', $delta = 0.0, 10, true); // Not caring about keys |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mais il faut aussi tester que les options optionnelles existent toujours.
| $userPasswordEncoderMock = $this->prophesize(UserPasswordEncoderInterface::class); | ||
| $userPasswordEncoderMock->isPasswordValid(Argument::type(UserInterface::class), 'password_test')->willReturn(true)->shouldBeCalled(); | ||
| /** @var UserPasswordEncoderInterface $userPasswordEncoder */ | ||
| $userPasswordEncoder = $userPasswordEncoderMock->reveal(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fait le dans le constructeur
| /** @var LoginAttempt $loginAttempt */ | ||
| $loginAttempt = $loginAttemptMock->reveal(); | ||
|
|
||
| $actualAccount = $passwordGrantExtension->grant($application, $loginAttempt); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
$actualAccount = $passwordGrantExtension->grant(
$application->reveal(),
$loginAttempt->reveal()
);|
@Raphy please squash your commits ! |
| $this->assertEquals($expectedRequiredOptions, $actualRequiredOptions, '', $delta = 0.0, 10, true); // Not caring about keys | ||
|
|
||
| // Testing the optional options | ||
| $actualOptionalOptions = array_diff($optionsResolver->getDefinedOptions(), $actualRequiredOptions); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pourquoi faire la distinction ? Ce que tu veux tester ici, c'est que les options définies le sont toujours, une option obligatoire est requise donc tu peux la tester.
|
Oui squash les commits ;) 📦 |
No description provided.