コード例 #1
0
 public function testFailureOlderThan2MonthsAreRemovedOnFailure()
 {
     self::$DI['app']['EM']->getEventManager()->removeEventSubscriber(new TimestampableListener());
     $recaptcha = $this->getReCaptchaMock(null);
     $ip = '192.168.16.178';
     $username = '******';
     $request = $this->getRequestMock();
     $request->expects($this->any())->method('getClientIp')->will($this->returnValue($ip));
     $this->assertCount(10, self::$DI['app']['EM']->getRepository('Phraseanet:AuthFailure')->findOldFailures());
     $this->assertCount(12, self::$DI['app']['EM']->getRepository('Phraseanet:AuthFailure')->findAll());
     $manager = new FailureManager(self::$DI['app']['repo.auth-failures'], self::$DI['app']['EM'], $recaptcha, 9);
     $manager->saveFailure($username, $request);
     $this->assertCount(0, self::$DI['app']['EM']->getRepository('Phraseanet:AuthFailure')->findOldFailures());
     $this->assertCount(3, self::$DI['app']['EM']->getRepository('Phraseanet:AuthFailure')->findAll());
     self::$DI['app']['EM']->getEventManager()->addEventSubscriber(new TimestampableListener());
 }