setTables(array('xxx' => array(array('id' => 1, 'title' => 'Live')))); } private function story(array $fields = array()): array { return $fields + array('title' => 'My story', 'author' => 'Vi', 'email' => 'vi@example.org', 'story' => '

Once -- upon a "time".

'); } public function testPlainHttpIsSentToHttps(): void { $this->assertRedirect('https://xxx.org.za/publish', $this->get('/publish', array('X-Test-Plain' => '1'))); } public function testTheFormHasATokenAndTheCaptcha(): void { $page = $this->get('/publish'); $this->assertSame(200, $page['status']); $this->assertSame($this->session()['csrf_token'], $this->csrfToken($page['body'])); $this->assertStringContainsString('
', $page['body']); $this->assertStringContainsString('https://www.google.com/recaptcha/api.js', $page['body']); $this->assertStringContainsString('', $page['body']); } public function testEditorsGetNoCaptcha(): void { $this->loginAs(); $body = $this->get('/publish')['body']; $this->assertStringNotContainsString('recaptcha', $body); } public function testPreviewThenSubmitAddsTheStoryToTheQueue(): void { $token = $this->csrfToken($this->get('/publish')['body']); $preview = $this->post('/publish', $this->story(array('action' => 'preview', 'csrf_token' => $token, 'g-recaptcha-response' => 'pass'))); $this->assertStringContainsString('Please review your submission.', $preview['body']); // The preview shows the purified story; the typography comes when it is saved $this->assertStringContainsString('

Once -- upon a "time".

', $preview['body']); $this->assertStringContainsString('