Commit e38afc6d authored by webchick's avatar webchick

Issue #2122321 by StephaneQ, jhodgdon: Search_embedded_form test module is...

Issue #2122321 by StephaneQ, jhodgdon: Search_embedded_form test module is improperly using config instead of state.
parent 6f2c0ee4
......@@ -50,7 +50,7 @@ function setUp() {
search_update_totals();
// Set up a dummy initial count of times the form has been submitted.
$this->submit_count = \Drupal::config('search_embedded_form.settings')->get('submitted');
$this->submit_count = \Drupal::state()->get('search_embedded_form.submit_count');
$this->refreshVariables();
}
......@@ -63,7 +63,7 @@ function testEmbeddedForm() {
array('name' => 'John'),
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::config('search_embedded_form.settings')->get('submitted');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count;
......@@ -74,7 +74,7 @@ function testEmbeddedForm() {
array('name' => 'John'),
t('Send away'));
$this->assertText(t('Test form was submitted'), 'Form message appears');
$count = \Drupal::config('search_embedded_form.settings')->get('submitted');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
$this->assertEqual($this->submit_count + 1, $count, 'Form submission count is correct');
$this->submit_count = $count;
......@@ -84,7 +84,7 @@ function testEmbeddedForm() {
array('keys' => 'foo'),
t('Search'));
$this->assertNoText(t('Test form was submitted'), 'Form message does not appear');
$count = \Drupal::config('search_embedded_form.settings')->get('submitted');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
$this->assertEqual($this->submit_count, $count, 'Form submission count is correct');
$this->submit_count = $count;
}
......
......@@ -25,7 +25,7 @@ public function getFormID() {
* {@inheritdoc}
*/
public function buildForm(array $form, array &$form_state) {
$count = $this->config('search_embedded_form.settings')->get('submitted');
$count = \Drupal::state()->get('search_embedded_form.submit_count');
$form['name'] = array(
'#type' => 'textfield',
......@@ -49,9 +49,9 @@ public function buildForm(array $form, array &$form_state) {
* {@inheritdoc}
*/
public function submitForm(array &$form, array &$form_state) {
$config = $this->config('search_embedded_form.settings');
$submit_count = (int) $config->get('submitted');
$config->set('submitted', $submit_count + 1)->save();
$state = \Drupal::state();
$submit_count = (int) $state->get('search_embedded_form.submit_count');
$state->set('search_embedded_form.submit_count', $submit_count + 1);
drupal_set_message($this->t('Test form was submitted'));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment