function EntityLoadTestCase::testEntityLoadInvalidControllerClass
Tests the controller class loading functionality on non-existing entity types and on entities without valid controller class.
File
-
modules/
simpletest/ tests/ entity_crud.test, line 66
Class
- EntityLoadTestCase
- Tests the entity_load() function.
Code
public function testEntityLoadInvalidControllerClass() {
// Ensure that loading a non-existing entity type will throw an
// EntityMalformedException.
try {
entity_load('test', array(
'1',
));
$this->fail(t('Cannot load a controller class on non-existing entity type.'));
} catch (EntityMalformedException $e) {
$this->pass(t('Cannot load a controller class on non-existing entity type.'));
}
// Ensure that loading an entity without valid controller class will throw
// an EntityMalformedException.
module_enable(array(
'entity_crud_hook_test',
));
variable_set('entity_crud_hook_test_alter_controller_class', TRUE);
try {
entity_load('node', array(
'1',
));
$this->fail(t('Cannot load a missing or non-existent controller class.'));
} catch (EntityMalformedException $e) {
$this->pass(t('Cannot load a missing or non-existent controller class.'));
}
variable_set('entity_crud_hook_test_alter_controller_class', FALSE);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.