class StateValuesCleanAdvancedTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest
- 10 core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest
- 8.9.x core/modules/system/tests/src/Functional/Form/StateValuesCleanAdvancedTest.php \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest
Tests the removal of internal Form API elements from submitted form values.
@group Form
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\system\Functional\Form\StateValuesCleanAdvancedTest uses \Drupal\Tests\TestFileCreationTrait extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of StateValuesCleanAdvancedTest
File
-
core/
modules/ system/ tests/ src/ Functional/ Form/ StateValuesCleanAdvancedTest.php, line 13
Namespace
Drupal\Tests\system\Functional\FormView source
class StateValuesCleanAdvancedTest extends BrowserTestBase {
use TestFileCreationTrait {
getTestFiles as drupalGetTestFiles;
}
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'file',
'form_test',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* An image file path for uploading.
*
* @var string|bool
*/
protected $image;
/**
* Tests \Drupal\Core\Form\FormState::cleanValues().
*/
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!");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.