You are here

public function StoreTest::testDuplicateStore in Commerce Core 8.2

Tests duplicating a store.

File

modules/store/tests/src/FunctionalJavascript/StoreTest.php, line 88

Class

StoreTest
Tests the store UI.

Namespace

Drupal\Tests\commerce_store\FunctionalJavascript

Code

public function testDuplicateStore() {
  $store = $this
    ->createStore('Test');
  $this
    ->drupalGet($store
    ->toUrl('duplicate-form'));
  $edit = [
    'name[0][value]' => 'Test2',
  ];
  $this
    ->submitForm($edit, 'Save');
  $this
    ->assertSession()
    ->pageTextContains('Saved the Test2 store.');

  // Confirm that the original store is unchanged.
  $store = $this
    ->reloadEntity($store);
  $this
    ->assertEquals('Test', $store
    ->label());

  // Confirm that the new store type has the expected data.
  $store = Store::load($store
    ->id() + 1);
  $this
    ->assertNotEmpty($store);
  $this
    ->assertEquals('Test2', $store
    ->label());
}