Commit d6956b25 authored by czigor's avatar czigor Committed by bojanz
Browse files

Issue #3032077 by czigor: AddressDefaultWidgetTest extends deprecated base class

parent c77245bc
...@@ -6,7 +6,7 @@ use Drupal\Component\Render\FormattableMarkup; ...@@ -6,7 +6,7 @@ use Drupal\Component\Render\FormattableMarkup;
use Drupal\Core\Entity\Entity\EntityFormDisplay; use Drupal\Core\Entity\Entity\EntityFormDisplay;
use Drupal\field\Entity\FieldConfig; use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig; use Drupal\field\Entity\FieldStorageConfig;
use Drupal\FunctionalJavascriptTests\JavascriptTestBase; use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\node\Entity\NodeType; use Drupal\node\Entity\NodeType;
/** /**
...@@ -14,7 +14,7 @@ use Drupal\node\Entity\NodeType; ...@@ -14,7 +14,7 @@ use Drupal\node\Entity\NodeType;
* *
* @group address * @group address
*/ */
class AddressDefaultWidgetTest extends JavascriptTestBase { class AddressDefaultWidgetTest extends WebDriverTestBase {
/** /**
* Modules to enable. * Modules to enable.
...@@ -98,7 +98,7 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -98,7 +98,7 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
$type->save(); $type->save();
// Create user that will be used for tests. // Create user that will be used for tests.
$this->adminUser = $this->drupalCreateUser([ $this->adminUser = $this->createUser([
'create article content', 'create article content',
'edit own article content', 'edit own article content',
'administer content types', 'administer content types',
...@@ -182,7 +182,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -182,7 +182,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
}, $countries); }, $countries);
$this->drupalGet($this->fieldConfigUrl); $this->drupalGet($this->fieldConfigUrl);
$this->submitForm($edit, t('Save settings')); $this->submitForm($edit, t('Save settings'));
$this->assertSession()->statusCodeEquals(200);
$this->drupalGet($this->nodeAddUrl); $this->drupalGet($this->nodeAddUrl);
$this->assertOptions($field_name . '[0][address][country_code]', $countries, 'The restricted list of available countries is present.'); $this->assertOptions($field_name . '[0][address][country_code]', $countries, 'The restricted list of available countries is present.');
...@@ -207,7 +206,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -207,7 +206,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
$edit[$path] = $value; $edit[$path] = $value;
} }
$this->submitForm($edit, t('Save')); $this->submitForm($edit, t('Save'));
$this->assertSession()->statusCodeEquals(200);
// Check that the article has been created. // Check that the article has been created.
$node = $this->getNodeByTitle($edit['title[0][value]']); $node = $this->getNodeByTitle($edit['title[0][value]']);
$this->assertNotEmpty($node, 'Created article ' . $edit['title[0][value]']); $this->assertNotEmpty($node, 'Created article ' . $edit['title[0][value]']);
...@@ -342,7 +340,7 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -342,7 +340,7 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
// Make one assert instead of many asserts for each field's existence. // Make one assert instead of many asserts for each field's existence.
$elements = $this->xpath('//input[starts-with(@name,"' . $field_name . '")] | //select[starts-with(@name,"' . $field_name . '")]'); $elements = $this->xpath('//input[starts-with(@name,"' . $field_name . '")] | //select[starts-with(@name,"' . $field_name . '")]');
$form_fields = []; $form_fields = [];
foreach ($elements as $key => $element) { foreach ($elements as $element) {
if ($field = array_search($element->getAttribute('name'), $all_fields)) { if ($field = array_search($element->getAttribute('name'), $all_fields)) {
$form_fields[] = $field; $form_fields[] = $field;
} }
...@@ -359,7 +357,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -359,7 +357,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
]; ];
$this->drupalGet($this->fieldConfigUrl); $this->drupalGet($this->fieldConfigUrl);
$this->submitForm($edit, t('Save settings')); $this->submitForm($edit, t('Save settings'));
$this->assertSession()->statusCodeEquals(200);
$this->drupalGet($this->nodeAddUrl); $this->drupalGet($this->nodeAddUrl);
$this->assertEmpty((bool) $this->xpath('//input[@name="field_address[0][address][given_name]" and contains(@required, "required")]')); $this->assertEmpty((bool) $this->xpath('//input[@name="field_address[0][address][given_name]" and contains(@required, "required")]'));
...@@ -381,7 +378,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -381,7 +378,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
$edit[$field_name . '[0][address][locality]'] = 'Mountain View'; $edit[$field_name . '[0][address][locality]'] = 'Mountain View';
$edit[$field_name . '[0][address][administrative_area]'] = 'CA'; $edit[$field_name . '[0][address][administrative_area]'] = 'CA';
$this->submitForm($edit, t('Save')); $this->submitForm($edit, t('Save'));
$this->assertSession()->statusCodeEquals(200);
$node = $this->getNodeByTitle($edit['title[0][value]']); $node = $this->getNodeByTitle($edit['title[0][value]']);
$this->assertNotEmpty($node, 'Created article ' . $edit['title[0][value]']); $this->assertNotEmpty($node, 'Created article ' . $edit['title[0][value]']);
} }
...@@ -440,7 +436,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -440,7 +436,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
$edit[$field_name . '[0][address][administrative_area]'] = 'CA'; $edit[$field_name . '[0][address][administrative_area]'] = 'CA';
$edit[$field_name . '[0][address][postal_code]'] = '94043'; $edit[$field_name . '[0][address][postal_code]'] = '94043';
$this->submitForm($edit, t('Save')); $this->submitForm($edit, t('Save'));
$this->assertSession()->statusCodeEquals(200);
$node = $this->getNodeByTitle($edit['title[0][value]']); $node = $this->getNodeByTitle($edit['title[0][value]']);
$this->drupalGet('node/' . $node->id() . '/edit'); $this->drupalGet('node/' . $node->id() . '/edit');
...@@ -454,7 +449,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase { ...@@ -454,7 +449,6 @@ class AddressDefaultWidgetTest extends JavascriptTestBase {
$this->getSession()->getPage()->fillField($field_name . '[0][address][country_code]', 'CN'); $this->getSession()->getPage()->fillField($field_name . '[0][address][country_code]', 'CN');
$this->waitForAjaxToFinish(); $this->waitForAjaxToFinish();
$this->submitForm([], t('Save')); $this->submitForm([], t('Save'));
$this->assertSession()->statusCodeEquals(200);
// Check that values are cleared. // Check that values are cleared.
$this->assertSession()->fieldValueEquals($field_name . '[0][address][country_code]', 'CN'); $this->assertSession()->fieldValueEquals($field_name . '[0][address][country_code]', 'CN');
$this->assertSession()->fieldValueEquals($field_name . '[0][address][administrative_area]', ''); $this->assertSession()->fieldValueEquals($field_name . '[0][address][administrative_area]', '');
......
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