public function StoreTest::testCreateStore in Commerce Core 8.2
Tests creating a store.
File
- modules/
store/ tests/ src/ FunctionalJavascript/ StoreTest.php, line 34
Class
- StoreTest
- Tests the store UI.
Namespace
Drupal\Tests\commerce_store\FunctionalJavascriptCode
public function testCreateStore() {
$this
->drupalGet('admin/commerce/config/stores');
$this
->getSession()
->getPage()
->clickLink('Add store');
// Check the integrity of the form.
$this
->assertSession()
->fieldExists('name[0][value]');
$this
->assertSession()
->fieldExists('mail[0][value]');
$this
->assertSession()
->fieldExists('address[0][address][country_code]');
$this
->assertSession()
->fieldExists('billing_countries[]');
$this
->assertSession()
->fieldExists('is_default[value]');
$this
->getSession()
->getPage()
->fillField('address[0][address][country_code]', 'US');
$this
->getSession()
->wait(4000, 'jQuery(\'select[name="address[0][address][administrative_area]"]\').length > 0 && jQuery.active == 0;');
$name = $this
->randomMachineName(8);
$edit = [
'name[0][value]' => $name,
'mail[0][value]' => \Drupal::currentUser()
->getEmail(),
'default_currency' => 'USD',
'timezone' => 'UTC',
];
$address = [
'address_line1' => '1098 Alta Ave',
'locality' => 'Mountain View',
'administrative_area' => 'CA',
'postal_code' => '94043',
];
foreach ($address as $property => $value) {
$path = 'address[0][address][' . $property . ']';
$edit[$path] = $value;
}
$this
->submitForm($edit, t('Save'));
$this
->assertSession()
->pageTextContains("Saved the {$name} store.");
}