Skip to content

Commit

Permalink
[BUGFIX] use findOneByIdentifier to select by „identifier“ not by „ui…
Browse files Browse the repository at this point in the history
…d“ in tests
  • Loading branch information
TomSchenk committed Sep 23, 2019
1 parent fac7686 commit f3b6cfd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ public function isNotClientRestrictedWhenMaximumNumbersOfFailureNotReached()
$this->configuration->expects($this->any())->method('getMaximumNumberOfFailures')->will($this->returnValue(10));
$this->configuration->expects($this->any())->method('getResetTime')->will($this->returnValue(300));
$this->configuration->expects($this->any())->method('getRestrictionTime')->will($this->returnValue(3000));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);

$entry = $this->getMockBuilder('Aoe\FeloginBruteforceProtection\Domain\Model\Entry')->getMock();
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(0));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 200));

$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);

Expand All @@ -147,8 +147,8 @@ public function isClientRestrictedWithFailures()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(10));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 400));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertTrue($this->restriction->isClientRestricted());
Expand All @@ -167,8 +167,8 @@ public function isClientRestrictedWithFailuresAndTimeout()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(10));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 200));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 4000));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertFalse($this->restriction->isClientRestricted());
Expand All @@ -187,8 +187,8 @@ public function isClientRestrictedWithLessFailures()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(5));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 400));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertFalse($this->restriction->isClientRestricted());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,12 @@ public function isClientRestricted()
$this->configuration->expects($this->any())->method('getResetTime')->will($this->returnValue(300));
$this->configuration->expects($this->any())->method('getRestrictionTime')->will($this->returnValue(3000));

$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);

$entry = $this->getMockBuilder('Aoe\FeloginBruteforceProtection\Domain\Model\Entry')->getMock();
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(0));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);

Expand All @@ -144,8 +144,8 @@ public function isClientRestrictedWithFailures()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(10));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 400));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertTrue($this->restriction->isClientRestricted());
Expand All @@ -163,8 +163,8 @@ public function isClientRestrictedWithFailuresAndTimeout()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(10));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 4000));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertFalse($this->restriction->isClientRestricted());
Expand All @@ -182,8 +182,8 @@ public function isClientRestrictedWithLessFailures()
$entry->expects($this->any())->method('getFailures')->will($this->returnValue(5));
$entry->expects($this->any())->method('getCrdate')->will($this->returnValue(time() - 400));
$entry->expects($this->any())->method('getTstamp')->will($this->returnValue(time() - 400));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findByIdentifier')->will($this->returnValue($entry));
$entryRepository = $this->getAccessibleMock(EntryRepository::class, ['findOneByIdentifier', 'remove'], [], '', false);
$entryRepository->expects($this->any())->method('findOneByIdentifier')->will($this->returnValue($entry));
$this->inject($this->restriction, 'entryRepository', $entryRepository);
$this->inject($this->restriction, 'configuration', $this->configuration);
$this->assertFalse($this->restriction->isClientRestricted());
Expand Down

0 comments on commit f3b6cfd

Please sign in to comment.