This commit is contained in:
@ -41,6 +41,56 @@ final class ClientsLifecycleTest extends QdbTestCase
|
||||
$this->assertSame($code, $res['data']['clientCode']);
|
||||
}
|
||||
|
||||
public function testArchiveHidesClientFromListsAndFollowUp(): void
|
||||
{
|
||||
$this->submitFixtureQuestionnaire();
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
DatabaseSeeder::ADMIN_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
)['token'];
|
||||
$code = $this->fixture()->clientCode;
|
||||
|
||||
$archive = $this->api()->withToken($token, 'PATCH', 'clients', [
|
||||
'clientCode' => $code,
|
||||
'archived' => true,
|
||||
]);
|
||||
$this->assertApiOk($archive);
|
||||
$this->assertSame(1, (int)($archive['data']['archived'] ?? 0));
|
||||
|
||||
$active = $this->api()->withToken($token, 'GET', 'clients');
|
||||
$this->assertApiOk($active);
|
||||
$activeCodes = array_column($active['data']['clients'], 'clientCode');
|
||||
$this->assertNotContains($code, $activeCodes);
|
||||
|
||||
$archivedOnly = $this->api()->withToken($token, 'GET', 'clients', null, [
|
||||
'archiveFilter' => 'archived',
|
||||
]);
|
||||
$this->assertApiOk($archivedOnly);
|
||||
$archivedCodes = array_column($archivedOnly['data']['clients'], 'clientCode');
|
||||
$this->assertContains($code, $archivedCodes);
|
||||
|
||||
$assign = $this->api()->withToken($token, 'GET', 'assignments');
|
||||
$this->assertApiOk($assign);
|
||||
$assignCodes = array_column($assign['data']['clients'], 'clientCode');
|
||||
$this->assertNotContains($code, $assignCodes);
|
||||
|
||||
$stale = $this->api()->withToken($token, 'GET', 'analytics', null, ['staleClients' => '1']);
|
||||
$this->assertApiOk($stale);
|
||||
$staleCodes = array_column($stale['data']['clients'], 'clientCode');
|
||||
$this->assertNotContains($code, $staleCodes);
|
||||
|
||||
$restore = $this->api()->withToken($token, 'PATCH', 'clients', [
|
||||
'clientCode' => $code,
|
||||
'archived' => false,
|
||||
]);
|
||||
$this->assertApiOk($restore);
|
||||
$this->assertSame(0, (int)($restore['data']['archived'] ?? 1));
|
||||
|
||||
$activeAgain = $this->api()->withToken($token, 'GET', 'clients');
|
||||
$this->assertApiOk($activeAgain);
|
||||
$this->assertContains($code, array_column($activeAgain['data']['clients'], 'clientCode'));
|
||||
}
|
||||
|
||||
public function testAdminDeletesClient(): void
|
||||
{
|
||||
$token = $this->api()->loginWebAndGetToken(
|
||||
|
||||
@ -11,8 +11,12 @@ final class RbacTest extends TestCase
|
||||
public function testAdminSeesAllClients(): void
|
||||
{
|
||||
[$clause, $params] = rbac_client_filter(['role' => 'admin', 'entityID' => 'a1'], 'cl');
|
||||
$this->assertSame('1=1', $clause);
|
||||
$this->assertStringContainsString('1=1', $clause);
|
||||
$this->assertStringContainsString('archived', $clause);
|
||||
$this->assertSame([], $params);
|
||||
|
||||
[$allClause] = rbac_client_filter(['role' => 'admin', 'entityID' => 'a1'], 'cl', 'all');
|
||||
$this->assertStringNotContainsString('archived', $allClause);
|
||||
}
|
||||
|
||||
public function testSupervisorFilterBindsEntity(): void
|
||||
|
||||
Reference in New Issue
Block a user