protected $defaultTheme = 'stark';
/**
* Tests using an object as the form callback.
*
* @see \Drupal\form_test\EventSubscriber\FormTestEventSubscriber::onKernelRequest()
*/
public function testObjectFormCallback() { $config_factory =
$this->container->
get('config.factory'
);
$this->
drupalGet('form-test/object-builder'
);
$this->
assertSession()->
pageTextContains('The FormTestObject::buildForm() method was used for this form.'
);
$this->
assertSession()->
elementExists('xpath', '//form[@id="form-test-form-test-object"]'
);
$this->
submitForm(['bananas' => 'green'
], 'Save'
);
$this->
assertSession()->
pageTextContains('The FormTestObject::validateForm() method was used for this form.'
);
$this->
assertSession()->
pageTextContains('The FormTestObject::submitForm() method was used for this form.'
);
$value =
$config_factory->
get('form_test.object'
)->
get('bananas'
);
$this->
assertSame('green',
$value);
$this->
drupalGet('form-test/object-arguments-builder/yellow'
);
$this->
assertSession()->
pageTextContains('The FormTestArgumentsObject::buildForm() method was used for this form.'
);
$this->
assertSession()->
elementExists('xpath', '//form[@id="form-test-form-test-arguments-object"]'
);
$this->
submitForm([], 'Save'
);