-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
052da93
commit beb5467
Showing
9 changed files
with
90 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
bootstrap="features/app/bootstrap.php" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
> | ||
<php> | ||
<ini name="display_errors" value="1" /> | ||
<ini name="error_reporting" value="-1" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="CoopTilleulsForgotPasswordBundle tests suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true"> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,33 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- https://phpunit.de/manual/current/en/appendixes.configuration.html --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd" backupGlobals="false" colors="true" bootstrap="features/app/bootstrap.php"> | ||
<coverage> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
<exclude> | ||
<directory>tests</directory> | ||
<directory>features</directory> | ||
<directory>vendor</directory> | ||
</exclude> | ||
</coverage> | ||
<php> | ||
<ini name="error_reporting" value="-1"/> | ||
<env name="SYMFONY_PHPUNIT_VERSION" value="9.5"/> | ||
<env name="SYMFONY_DEPRECATIONS_HELPER" value="disabled" /> | ||
</php> | ||
<testsuites> | ||
<testsuite name="CoopTilleulsForgotPasswordBundle tests suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd" | ||
backupGlobals="false" | ||
colors="true" | ||
bootstrap="features/app/bootstrap.php" | ||
failOnWarning="true" | ||
failOnRisky="true" | ||
failOnDeprecation="true" | ||
failOnNotice="true" | ||
displayDetailsOnTestsThatTriggerDeprecations="true" | ||
displayDetailsOnTestsThatTriggerErrors="true" | ||
displayDetailsOnTestsThatTriggerNotices="true" | ||
displayDetailsOnTestsThatTriggerWarnings="true" | ||
> | ||
<php> | ||
<ini name="display_errors" value="1" /> | ||
<ini name="error_reporting" value="-1" /> | ||
</php> | ||
|
||
<testsuites> | ||
<testsuite name="CoopTilleulsForgotPasswordBundle tests suite"> | ||
<directory>tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<source ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true"> | ||
<include> | ||
<directory>src</directory> | ||
</include> | ||
</source> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,7 +67,6 @@ protected function setUp(): void | |
|
||
public function testResetPasswordNotUser(): void | ||
{ | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); | ||
$this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); | ||
$this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => '[email protected]']); | ||
|
@@ -79,12 +78,11 @@ public function testResetPasswordNotUser(): void | |
|
||
$this->passwordManagerMock->expects($this->never())->method('findOneByUser')->with(self::any(), $this->providerMock); | ||
|
||
$this->manager->resetPassword('email', '[email protected]'); | ||
$this->manager->resetPassword('email', '[email protected]', $this->providerMock); | ||
} | ||
|
||
public function testResetPasswordWithNoPreviousToken(): void | ||
{ | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); | ||
$this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); | ||
$this->providerMock->expects($this->once())->method('getPasswordTokenExpiredIn')->willReturn('+1 day'); | ||
|
@@ -98,12 +96,11 @@ public function testResetPasswordWithNoPreviousToken(): void | |
$this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(fn ($event) => $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken())); | ||
} | ||
|
||
$this->manager->resetPassword('email', '[email protected]'); | ||
$this->manager->resetPassword('email', '[email protected]', $this->providerMock); | ||
} | ||
|
||
public function testResetPasswordWithExpiredPreviousToken(): void | ||
{ | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); | ||
$this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); | ||
$this->providerMock->expects($this->once())->method('getPasswordTokenExpiredIn')->willReturn('+1 day'); | ||
|
@@ -118,19 +115,17 @@ public function testResetPasswordWithExpiredPreviousToken(): void | |
$this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(fn ($event) => $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken())); | ||
} | ||
|
||
$this->manager->resetPassword('email', '[email protected]'); | ||
$this->manager->resetPassword('email', '[email protected]', $this->providerMock); | ||
} | ||
|
||
/** | ||
* @see https://github.com/coopTilleuls/CoopTilleulsForgotPasswordBundle/issues/37 | ||
*/ | ||
public function testResetPasswordWithUnexpiredTokenHttp(): void | ||
{ | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); | ||
$this->providerMock->expects($this->once())->method('getUserClass')->willReturn(User::class); | ||
$this->tokenMock->expects($this->once())->method('isExpired')->willReturn(false); | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->managerMock->expects($this->once())->method('findOneBy')->with(User::class, ['email' => '[email protected]'])->willReturn($this->userMock); | ||
$this->passwordManagerMock->expects($this->once())->method('findOneByUser')->with($this->userMock, $this->providerMock)->willReturn($this->tokenMock); | ||
|
||
|
@@ -140,12 +135,11 @@ public function testResetPasswordWithUnexpiredTokenHttp(): void | |
$this->eventDispatcherMock->expects($this->once())->method('dispatch')->with(ForgotPasswordEvent::CREATE_TOKEN, $this->callback(fn ($event) => $event instanceof CreateTokenEvent && null === $event->getPassword() && $this->tokenMock === $event->getPasswordToken())); | ||
} | ||
|
||
$this->manager->resetPassword('email', '[email protected]'); | ||
$this->manager->resetPassword('email', '[email protected]', $this->providerMock); | ||
} | ||
|
||
public function testUpdatePassword(): void | ||
{ | ||
$this->providerChainMock->expects($this->once())->method('get')->willReturn($this->providerMock); | ||
$this->providerMock->expects($this->once())->method('getManager')->willReturn($this->managerMock); | ||
|
||
if ($this->eventDispatcherMock instanceof ContractsEventDispatcherInterface) { | ||
|
@@ -155,6 +149,6 @@ public function testUpdatePassword(): void | |
} | ||
$this->managerMock->expects($this->once())->method('remove')->with($this->tokenMock); | ||
|
||
$this->manager->updatePassword($this->tokenMock, 'bar'); | ||
$this->manager->updatePassword($this->tokenMock, 'bar', $this->providerMock); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters