diff --git a/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php new file mode 100644 index 0000000..8accf9f --- /dev/null +++ b/phpunit/integration/GovCMS/Security/Functional/HttpavServiceTest.php @@ -0,0 +1,86 @@ +drupalCreateUser([]); + $this->drupalLogin($account); + + $this->testFile = $this->govcmsGenerateTestFile('image_1.png', $this->randomString());; + } + + /** + * {@inheritdoc} + */ + #[\Override] + protected function tearDown(): void { + // Delete all test file. + unlink($this->testFile); + + parent::tearDown(); + } + + /** + * Tests that file uploads fail if the HTTPAV service is unavailble. + */ + public function testMissingHttpavService() { + $file = $this->testFile; + + $edit = [ + 'files[file_test_upload][]' => $file, + ]; + // Go to the file upload test form provided by govcms_file_test module. + $this->drupalGet('govcms-file-test/save_upload_from_form_test'); + $this->submitForm($edit, 'Submit'); + + $this->assertSession()->pageTextContains('The anti-virus scanner could not check the file, the file cannot be uploaded.'); + $this->assertSession()->pageTextContains('Epic upload FAIL!'); + $this->assertFileDoesNotExist('temporary://' . basename((string) $file)); + } + +}