@@ -42,11 +42,18 @@ namespace Tests\App\Controllers\View {
|
||||
|
||||
$response = $this->controller->index();
|
||||
|
||||
$this->assertIsString($response);
|
||||
if (is_array($response)) {
|
||||
$this->assertSame('user/register', $response['view']);
|
||||
} else {
|
||||
$this->assertIsString($response);
|
||||
}
|
||||
$captcha = session()->get('captcha_answer');
|
||||
$this->assertNotEmpty($captcha);
|
||||
$this->assertGreaterThanOrEqual(4, strlen($captcha));
|
||||
$this->assertLessThanOrEqual(8, strlen($captcha));
|
||||
if (is_array($response)) {
|
||||
$this->assertSame($captcha, $response['data']['captchaQuestion']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testIndexReusesExistingCaptcha()
|
||||
@@ -55,8 +62,15 @@ namespace Tests\App\Controllers\View {
|
||||
|
||||
$response = $this->controller->index();
|
||||
|
||||
$this->assertIsString($response);
|
||||
if (is_array($response)) {
|
||||
$this->assertSame('user/register', $response['view']);
|
||||
} else {
|
||||
$this->assertIsString($response);
|
||||
}
|
||||
$this->assertSame('EXISTING', session()->get('captcha_answer'));
|
||||
if (is_array($response)) {
|
||||
$this->assertSame('EXISTING', $response['data']['captchaQuestion']);
|
||||
}
|
||||
}
|
||||
|
||||
public function testSuccessRedirectsWhenEmailMissing()
|
||||
@@ -75,7 +89,12 @@ namespace Tests\App\Controllers\View {
|
||||
|
||||
$response = $this->controller->success();
|
||||
|
||||
$this->assertIsString($response);
|
||||
if (is_array($response)) {
|
||||
$this->assertSame('success', $response['view']);
|
||||
$this->assertSame('parent@example.com', $response['data']['email']);
|
||||
} else {
|
||||
$this->assertIsString($response);
|
||||
}
|
||||
$this->assertSame('parent@example.com', session()->get('user_email'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user