/** * Tests deleting a store. */ public function testDeleteStore() { // Create a new store. $store = $this->createEntity('commerce_store', ['type' => $this->type->id(), 'name' => $this->randomMachineName(8), 'email' => \Drupal::currentUser()->getEmail()]); $store_exists = (bool) Store::load($store->id()); $this->assertTrue($store_exists, 'The new store has been created in the database.'); // Delete the Store and verify deletion. $store->delete(); $store_exists = (bool) Store::load($store->id()); $this->assertFalse($store_exists, 'The new store has been deleted from the database.'); }
/** * Tests deleting a store. */ public function testDeleteStore() { $store = $this->createStore(['type' => 'default', 'name' => $this->randomMachineName(8)]); $this->drupalGet($store->toUrl('delete-form')); $this->assertResponse(200, 'The store delete form can be accessed.'); $this->assertText(t('This action cannot be undone.'), 'The store delete confirmation form is available.'); $this->drupalPostForm(NULL, NULL, t('Delete')); \Drupal::service('entity_type.manager')->getStorage('commerce_store')->resetCache([$store->id()]); $store_exists = (bool) Store::load($store->id()); $this->assertFalse($store_exists, 'The new store has been deleted from the database using UI.'); }