Skip to content

Commit

Permalink
Merge pull request #3 from christyjacob4/master
Browse files Browse the repository at this point in the history
chore: changed function name
  • Loading branch information
eldadfux authored Dec 17, 2020
2 parents c86455f + 6957645 commit 5000fdb
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Audit/Adapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,5 @@ abstract public function getLogsByUserAndActions(string $userId, array $actions)
*
* @return bool
*/
abstract public function deleteLogsOlderThan(int $seconds): bool;
abstract public function cleanup(int $seconds): bool;
}
2 changes: 1 addition & 1 deletion src/Audit/Adapters/MySQL.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public function getLogsByUserAndActions(string $userId, array $actions):array
*
* @return bool
*/
public function deleteLogsOlderThan(int $seconds):bool
public function cleanup(int $seconds):bool
{
$st = $this->getPDO()->prepare('DELETE
FROM `'.$this->getNamespace().'.audit.audit`
Expand Down
4 changes: 2 additions & 2 deletions src/Audit/Audit.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ public function getLogsByUserAndActions(string $userId, array $actions): array
*
* @return bool
*/
public function deleteLogsOlderThan(int $seconds): bool
public function cleanup(int $seconds): bool
{
return $this->adapter->deleteLogsOlderThan($seconds);
return $this->adapter->cleanup($seconds);
}
}
6 changes: 3 additions & 3 deletions tests/Audit/AuditTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ public function testGetLogsByResource()
$this->assertEquals(2, \count($logs2));
}

public function testDeleteLogsOlderThan() {
public function testCleanup() {
sleep(3);
// First delete all the logs
$status = $this->audit->deleteLogsOlderThan(1);
$status = $this->audit->cleanup(1);
$this->assertEquals($status, true);

// Check that all logs have been deleted
Expand All @@ -118,7 +118,7 @@ public function testDeleteLogsOlderThan() {
sleep(5);

// DELETE logs older than 10 seconds and check that status is true
$status = $this->audit->deleteLogsOlderThan(10);
$status = $this->audit->cleanup(10);
$this->assertEquals($status, true);

// Check if 1 log has been deleted
Expand Down

0 comments on commit 5000fdb

Please sign in to comment.