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://site.test/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/enterprise.js', $page['body']); $this->assertStringContainsString('', $page['body']); } public function testTheImageTabKeepsTheSpaceOfTheNote(): void { $html = new \DOMDocument(); $html->loadHTML($this->get('/publish')['body'], LIBXML_NOERROR); $xpath = new \DOMXPath($html); $note = $xpath->query('//div[@id="textparent"]/div[@class="note"]'); $spacer = $xpath->query('//div[@id="uploadparent"]/div[@class="note spacer"][@aria-hidden="true"]'); $this->assertCount(1, $note); $this->assertCount(1, $spacer); $this->assertSame($note[0]->textContent, $spacer[0]->textContent); $this->assertCount(1, $xpath->query('//div[@id="uploadparent"]/div[@class="upload"]//input[@id="upload"]')); // Both tabs sit in the same column $this->assertCount(2, $xpath->query('//div[@class="textarea rightcolumn"]/div[@id="textparent" or @id="uploadparent"]')); } 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('