This commit is contained in:
@ -58,4 +58,42 @@ final class AppQuestionnairesTest extends QdbTestCase
|
||||
$codes = array_column($payload['clients'], 'clientCode');
|
||||
$this->assertContains($this->fixture()->clientCode, $codes);
|
||||
}
|
||||
|
||||
public function testCoachClientNoteRoundTrip(): void
|
||||
{
|
||||
$this->submitFixtureQuestionnaire();
|
||||
$login = $this->api()->loginMobileAndGetToken(
|
||||
DatabaseSeeder::COACH_USERNAME,
|
||||
DatabaseSeeder::PASSWORD
|
||||
);
|
||||
$code = $this->fixture()->clientCode;
|
||||
$note = 'Bitte Rückruf nächste Woche';
|
||||
|
||||
$save = $this->api()->encryptedPost($login['token'], 'app_questionnaires', [
|
||||
'action' => 'setClientNote',
|
||||
'clientCode' => $code,
|
||||
'note' => $note,
|
||||
]);
|
||||
$this->assertApiOk($save);
|
||||
$this->assertTrue($save['data']['encrypted'] ?? false);
|
||||
$savedPlain = qdb_decrypt_sensitive_envelope($save['data'], $login['token']);
|
||||
$savedPayload = json_decode($savedPlain, true, 512, JSON_THROW_ON_ERROR);
|
||||
$this->assertSame($note, $savedPayload['note']);
|
||||
|
||||
$list = $this->api()->withMobileToken($login['token'], 'GET', 'app_questionnaires', null, [
|
||||
'clients' => '1',
|
||||
]);
|
||||
$this->assertApiOk($list);
|
||||
$listPlain = qdb_decrypt_sensitive_envelope($list['data'], $login['token']);
|
||||
$listPayload = json_decode($listPlain, true, 512, JSON_THROW_ON_ERROR);
|
||||
$match = null;
|
||||
foreach ($listPayload['clients'] as $row) {
|
||||
if (($row['clientCode'] ?? '') === $code) {
|
||||
$match = $row;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$this->assertIsArray($match);
|
||||
$this->assertSame($note, $match['note'] ?? null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user