forked from fa/breadcrumb-the-shire
65 lines
2.4 KiB
PHP
65 lines
2.4 KiB
PHP
|
|
<?php
|
||
|
|
|
||
|
|
namespace MintyPHP\Tests\Service\User;
|
||
|
|
|
||
|
|
use MintyPHP\Repository\User\UserLifecyclePolicyDashboardRepositoryInterface;
|
||
|
|
use MintyPHP\Service\User\UserLifecyclePolicyDashboardService;
|
||
|
|
use PHPUnit\Framework\TestCase;
|
||
|
|
|
||
|
|
class UserLifecyclePolicyDashboardServiceTest extends TestCase
|
||
|
|
{
|
||
|
|
public function testReturnsZeroWhenDeactivateDaysIsZero(): void
|
||
|
|
{
|
||
|
|
$repository = $this->createMock(UserLifecyclePolicyDashboardRepositoryInterface::class);
|
||
|
|
$repository->expects($this->never())->method('countPendingDeletion');
|
||
|
|
|
||
|
|
$service = new UserLifecyclePolicyDashboardService($repository);
|
||
|
|
|
||
|
|
$this->assertSame(0, $service->pendingDeletionCount(0, 365, 7));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testReturnsZeroWhenDeleteDaysIsZero(): void
|
||
|
|
{
|
||
|
|
$repository = $this->createMock(UserLifecyclePolicyDashboardRepositoryInterface::class);
|
||
|
|
$repository->expects($this->never())->method('countPendingDeletion');
|
||
|
|
|
||
|
|
$service = new UserLifecyclePolicyDashboardService($repository);
|
||
|
|
|
||
|
|
$this->assertSame(0, $service->pendingDeletionCount(180, 0, 7));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testReturnsZeroWhenWindowDaysIsZeroOrNegative(): void
|
||
|
|
{
|
||
|
|
$repository = $this->createMock(UserLifecyclePolicyDashboardRepositoryInterface::class);
|
||
|
|
$repository->expects($this->never())->method('countPendingDeletion');
|
||
|
|
|
||
|
|
$service = new UserLifecyclePolicyDashboardService($repository);
|
||
|
|
|
||
|
|
$this->assertSame(0, $service->pendingDeletionCount(180, 365, 0));
|
||
|
|
$this->assertSame(0, $service->pendingDeletionCount(180, 365, -1));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testDelegatesToRepositoryWhenAllPolicyValuesPositive(): void
|
||
|
|
{
|
||
|
|
$repository = $this->createMock(UserLifecyclePolicyDashboardRepositoryInterface::class);
|
||
|
|
$repository->expects($this->once())
|
||
|
|
->method('countPendingDeletion')
|
||
|
|
->with(365, 7)
|
||
|
|
->willReturn(42);
|
||
|
|
|
||
|
|
$service = new UserLifecyclePolicyDashboardService($repository);
|
||
|
|
|
||
|
|
$this->assertSame(42, $service->pendingDeletionCount(180, 365, 7));
|
||
|
|
}
|
||
|
|
|
||
|
|
public function testReturnsRepositoryCountVerbatim(): void
|
||
|
|
{
|
||
|
|
$repository = $this->createMock(UserLifecyclePolicyDashboardRepositoryInterface::class);
|
||
|
|
$repository->method('countPendingDeletion')->willReturn(0);
|
||
|
|
|
||
|
|
$service = new UserLifecyclePolicyDashboardService($repository);
|
||
|
|
|
||
|
|
$this->assertSame(0, $service->pendingDeletionCount(180, 365, 7));
|
||
|
|
}
|
||
|
|
}
|