public function StateValuesCleanAdvancedTest::testFormStateValuesCleanAdvanced in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest::testFormStateValuesCleanAdvanced()
- 9 core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest::testFormStateValuesCleanAdvanced()
Tests \Drupal\Core\Form\FormState::cleanValues().
File
- core/
modules/ system/ tests/ src/ Functional/ Form/ StateValuesCleanAdvancedTest.php, line 43
Class
- StateValuesCleanAdvancedTest
- Tests proper removal of submitted form values using \Drupal\Core\Form\FormState::cleanValues() when having forms with elements containing buttons like "managed_file".
Namespace
Drupal\Tests\system\Functional\FormCode
public function testFormStateValuesCleanAdvanced() {
// Get an image for uploading.
$image_files = $this
->drupalGetTestFiles('image');
$this->image = current($image_files);
// Check if the physical file is there.
$this
->assertFileExists($this->image->uri);
// "Browse" for the desired file.
$edit = [
'files[image]' => \Drupal::service('file_system')
->realpath($this->image->uri),
];
// Post the form.
$this
->drupalGet('form_test/form-state-values-clean-advanced');
$this
->submitForm($edit, 'Submit');
// Expecting a 200 HTTP code.
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->pageTextContains("You WIN!");
}