/** * {@inheritdoc} */ public function buildRow(EntityInterface $entity) { /* @var $entity \Drupal\commerce_store\Entity\Store */ $store_type = StoreType::load($entity->bundle()); $row['name']['data'] = ['#type' => 'link', '#title' => $entity->label()] + $entity->urlInfo()->toRenderArray(); $row['type'] = $store_type->label(); return $row + parent::buildRow($entity); }
/** * Tests deleting a Store Type through the form. */ public function testDeleteStoreType() { // Create a store type programmaticaly. $type = $this->createEntity('commerce_store_type', [ 'id' => 'foo', 'label' => 'Label for foo', ] ); // Create a store. $store = $this->createEntity('commerce_store', [ 'type' => $type->id(), 'name' => $this->randomMachineName(8), 'email' => \Drupal::currentUser()->getEmail(), ]); // Try to delete the store type. $this->drupalGet('admin/commerce/config/store-types/' . $type->id() . '/delete'); $this->assertRaw( t('%type is used by 1 store on your site. You can not remove this store type until you have removed all of the %type stores.', ['%type' => $type->label()]), 'The store type will not be deleted until all stores of that type are deleted' ); $this->assertNoText(t('This action cannot be undone.'), 'The store type deletion confirmation form is not available'); // Deleting the store type when its not being referenced by a store. $store->delete(); $this->drupalGet('admin/commerce/config/store-types/' . $type->id() . '/delete'); $this->assertRaw( t('Are you sure you want to delete the store type %type?', ['%type' => $type->label()]), 'The store type is available for deletion' ); $this->assertText(t('This action cannot be undone.'), 'The store type deletion confirmation form is available'); $this->drupalPostForm(NULL, NULL, t('Delete')); $typeExists = (bool) StoreType::load($type->id()); $this->assertFalse($typeExists, 'The new store type has been deleted from the database.'); }