public function WebformElementManagedFileTest::testFileUploadWithDisabledResults in Webform 8.5
Same name and namespace in other branches
- 6.x tests/src/Functional/Element/WebformElementManagedFileTest.php \Drupal\Tests\webform\Functional\Element\WebformElementManagedFileTest::testFileUploadWithDisabledResults()
Test file upload with disabled results.
File
- tests/
src/ Functional/ Element/ WebformElementManagedFileTest.php, line 262
Class
- WebformElementManagedFileTest
- Test for webform element managed file handling.
Namespace
Drupal\Tests\webform\Functional\ElementCode
public function testFileUploadWithDisabledResults() {
$this
->drupalLogin($this->rootUser);
$webform = Webform::load('test_element_managed_file_dis');
// Upload new file.
$sid = $this
->postSubmissionTest($webform);
$file = File::load($this
->getLastFileId());
// Check that no submission was saved to the database.
$this
->assertNull($sid);
// Check file URI.
$this
->assertEqual($file
->getFileUri(), 'private://webform/test_element_managed_file_dis/_sid_/managed_file.txt');
// Check file is temporary.
$this
->assertTrue($file
->isTemporary());
// Check file_managed table has 1 record.
$this
->assertEqual(1, \Drupal::database()
->query('SELECT COUNT(fid) AS total FROM {file_managed}')
->fetchField());
// Check file_usage table has no records.
$this
->assertEqual(0, \Drupal::database()
->query('SELECT COUNT(fid) AS total FROM {file_usage}')
->fetchField());
}