1 entity.test EntityAPIInfoTestCase::testEntityInfoChanges()

Ensures entity info cache is updated after changes.

File

core/modules/entity/tests/entity.test, line 68
Entity CRUD API tests.

Class

EntityAPIInfoTestCase
Tests Entity API base functionality.

Code

function testEntityInfoChanges() {
  module_enable(array('entity_cache_test'));
  $entity_info = entity_get_info();
  $this->assertTrue(isset($entity_info['entity_cache_test']), 'Test entity type found.');

  // Change the label of the test entity type and make sure changes appear
  // after flushing caches.
  state_set('entity_cache_test_label', 'New label.');
  backdrop_flush_all_caches();
  $info = entity_get_info('entity_cache_test');
  $this->assertEqual($info['label'], 'New label.', 'New label appears in entity info.');

  // Disable the providing module and make sure the entity type is gone.
  module_disable(array('entity_cache_test', 'entity_cache_test_dependency'));
  $entity_info = entity_get_info();
  $this->assertFalse(isset($entity_info['entity_cache_test']), 'Entity type of the providing module is gone.');
}