1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ApplicationTest\Repository; |
6
|
|
|
|
7
|
|
|
use Application\Model\Log; |
8
|
|
|
use Application\Repository\LogRepository; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @group Repository |
12
|
|
|
*/ |
13
|
|
|
class LogRepositoryTest extends AbstractRepositoryTest |
14
|
|
|
{ |
15
|
|
|
/** |
16
|
|
|
* @var LogRepository |
17
|
|
|
*/ |
18
|
|
|
private $repository; |
19
|
|
|
|
20
|
|
|
public function setUp(): void |
21
|
|
|
{ |
22
|
|
|
parent::setUp(); |
23
|
|
|
$this->repository = _em()->getRepository(Log::class); |
24
|
|
|
} |
25
|
|
|
|
26
|
|
|
public function testLoginFailedOften(): void |
27
|
|
|
{ |
28
|
|
|
$this->getEntityManager()->getConnection()->exec('DELETE FROM log'); |
29
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
30
|
|
|
|
31
|
|
|
$result = $this->repository->loginFailedOften(); |
32
|
|
|
self::assertFalse($result); |
33
|
|
|
|
34
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
35
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
36
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
37
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
38
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
39
|
|
|
_log()->info(LogRepository::LOGIN_FAILED); |
40
|
|
|
|
41
|
|
|
$result = $this->repository->loginFailedOften(); |
42
|
|
|
self::assertTrue($result, 'is your PHP date.timezone setting correct ?'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function testUpdatePasswordFailedOften(): void |
46
|
|
|
{ |
47
|
|
|
$this->getEntityManager()->getConnection()->exec('DELETE FROM log'); |
48
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
49
|
|
|
|
50
|
|
|
$result = $this->repository->updatePasswordFailedOften(); |
51
|
|
|
self::assertFalse($result); |
52
|
|
|
|
53
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
54
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
55
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
56
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
57
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
58
|
|
|
_log()->info(LogRepository::UPDATE_PASSWORD_FAILED); |
59
|
|
|
|
60
|
|
|
$result = $this->repository->updatePasswordFailedOften(); |
61
|
|
|
self::assertTrue($result, 'is your PHP date.timezone setting correct ?'); |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
public function testDeleteOldLogs(): void |
65
|
|
|
{ |
66
|
|
|
$result = $this->repository->deleteOldLogs(); |
67
|
|
|
self::assertSame(0, $result); |
68
|
|
|
} |
69
|
|
|
} |
70
|
|
|
|