Reject invalid uploads and expand flow tests.

This commit is contained in:
tim
2026-09-26 15:27:51 +02:00
parent 716a609f4e
commit 8f4851e576
9 changed files with 427 additions and 11 deletions
+18
View File
@@ -181,6 +181,24 @@ class SubmitTest extends PageTestCase {
$this->assertNotSame($first, $second);
}
#[DataProvider('uploadActions')]
public function testANestedUploadIsRejectedWithoutSaving(string $action): void {
$token = $this->csrfToken($this->get('/publish')['body']);
$before = $this->tables();
$page = $this->postFiles('/publish', $this->story(array('action' => $action, 'csrf_token' => $token,
'g-recaptcha-response' => 'pass')),
array('upload[]' => array('a.png', TestCase::png())));
$this->assertSame(200, $page['status']);
$this->assertStringContainsString('The upload is invalid. Please choose the image again.', $page['body']);
$this->assertSame($before, $this->tables());
$this->assertSame(array(), $this->uploads());
$this->assertArrayNotHasKey('pending_upload', $this->session());
}
public static function uploadActions(): array {
return array('preview' => array('preview'), 'submit' => array('submit'));
}
public function testAFailedCaptchaKeepsNoImage(): void {
$page = $this->previewImage(array('g-recaptcha-response' => 'fail'));
$this->assertStringContainsString('Please complete the captcha.', $page['body']);