Commit 9c668589 authored by webchick's avatar webchick

Issue #2216701 by alexpott, sun, longwave: Random test failure in ToolbarAdminMenuTest.

parent ba3a839c
......@@ -7,10 +7,9 @@
namespace Drupal\Core\Config\Entity;
use Drupal\Component\Utility\String;
use Drupal\Core\Entity\Entity;
use Drupal\Core\Config\ConfigDuplicateUUIDException;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Core\Config\ConfigDuplicateUUIDException;
/**
* Defines a base configuration entity class.
......@@ -126,8 +125,6 @@ public function set($property_name, $value) {
}
$this->{$property_name} = $value;
return $this;
}
/**
......@@ -164,8 +161,6 @@ public function status() {
*/
public function setSyncing($syncing) {
$this->isSyncing = $syncing;
return $this;
}
/**
......@@ -189,7 +184,7 @@ public function createDuplicate() {
/**
* Helper callback for uasort() to sort configuration entities by weight and label.
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
public static function sort($a, $b) {
$a_weight = isset($a->weight) ? $a->weight : 0;
$b_weight = isset($b->weight) ? $b->weight : 0;
if ($a_weight == $b_weight) {
......@@ -236,14 +231,14 @@ public function preSave(EntityStorageControllerInterface $storage_controller) {
->execute();
$matched_entity = reset($matching_entities);
if (!empty($matched_entity) && ($matched_entity != $this->id())) {
throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this UUID is already used for %matched', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%matched' => $matched_entity)));
}
if (!$this->isNew()) {
$original = $storage_controller->loadUnchanged($this->id());
// Ensure that the UUID cannot be changed for an existing entity.
if ($original && ($original->uuid() != $this->uuid())) {
throw new ConfigDuplicateUUIDException(String::format('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
throw new ConfigDuplicateUUIDException(format_string('Attempt to save a configuration entity %id with UUID %uuid when this entity already exists with UUID %original_uuid', array('%id' => $this->id(), '%uuid' => $this->uuid(), '%original_uuid' => $original->uuid())));
}
}
}
......
......@@ -28,21 +28,23 @@ public function getOriginalId();
* @param string $id
* The new ID to set as original ID.
*
* @return $this
* @return self
*/
public function setOriginalId($id);
/**
* Enables the configuration entity.
*
* @return $this
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface
* The configuration entity.
*/
public function enable();
/**
* Disables the configuration entity.
*
* @return $this
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface
* The configuration entity.
*/
public function disable();
......@@ -52,7 +54,8 @@ public function disable();
* @param bool $status
* The status of the configuration entity.
*
* @return $this
* @return \Drupal\Core\Config\Entity\ConfigEntityInterface
* The class instance that this method is called on.
*/
public function setStatus($status);
......@@ -61,8 +64,6 @@ public function setStatus($status);
*
* @param bool $status
* The status of the sync flag.
*
* @return $this
*/
public function setSyncing($status);
......@@ -108,8 +109,6 @@ public function get($property_name);
* The name of the property that should be set.
* @param mixed $value
* The value the property should be set to.
*
* @return $this
*/
public function set($property_name, $value);
......
......@@ -128,20 +128,13 @@ abstract class ContentEntityBase extends Entity implements \IteratorAggregate, C
*/
protected $isDefaultRevision = TRUE;
/**
* The typed data manager.
*
* @var \Drupal\Core\TypedData\TypedDataManager
*/
protected $typedDataManager;
/**
* Overrides Entity::__construct().
*/
public function __construct(array $values, $entity_type, $bundle = FALSE, $translations = array()) {
$this->entityTypeId = $entity_type;
$this->bundle = $bundle ? $bundle : $this->entityTypeId;
$this->languages = $this->languageList(Language::STATE_ALL);
$this->languages = language_list(Language::STATE_ALL);
foreach ($values as $key => $value) {
// If the key matches an existing property set the value to the property
......@@ -168,26 +161,6 @@ public function __construct(array $values, $entity_type, $bundle = FALSE, $trans
$this->init();
}
/**
* Wraps $this->languageList().
*/
protected function languageList($flags = Language::STATE_CONFIGURABLE) {
return language_list($flags);
}
/**
* Returns the typed data manager.
*
* @return \Drupal\Core\TypedData\TypedDataManager
*/
protected function typedDataManager() {
if (!$this->typedDataManager) {
$this->typedDataManager = \Drupal::typedDataManager();
}
return $this->typedDataManager;
}
/**
* {@inheritdoc}
*/
......@@ -224,7 +197,8 @@ public function getRevisionId() {
* {@inheritdoc}
*/
public function isTranslatable() {
$bundles = $this->entityManager()->getBundleInfo($this->entityTypeId);
// @todo Inject the entity manager and retrieve bundle info from it.
$bundles = entity_get_bundles($this->entityTypeId);
return !empty($bundles[$this->bundle()]['translatable']);
}
......@@ -265,14 +239,15 @@ public function setValue($value, $notify = TRUE) {
* {@inheritdoc}
*/
public function getString() {
return (string) $this->label();
return $this->label();
}
/**
* {@inheritdoc}
*/
public function validate() {
return $this->typedDataManager()->getValidator()->validate($this);
// @todo: Add the typed data manager as proper dependency.
return \Drupal::typedDataManager()->getValidator()->validate($this);
}
/**
......@@ -358,7 +333,10 @@ public function __sleep() {
$this->fieldDefinitions = NULL;
$this->clearTranslationCache();
return parent::__sleep();
// Don't serialize the url generator.
$this->urlGenerator = NULL;
return array_keys(get_object_vars($this));
}
......@@ -366,7 +344,6 @@ public function __sleep() {
* Magic __wakeup() implementation.
*/
public function __wakeup() {
parent::__wakeup();
$this->init();
}
......@@ -416,7 +393,7 @@ public function get($property_name) {
protected function getTranslatedField($name, $langcode) {
if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
$message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode)));
}
// Populate $this->fields to speed-up further look-ups and to keep track of
// fields objects, possibly holding changes to field values.
......@@ -549,13 +526,13 @@ public function isEmpty() {
/**
* {@inheritdoc}
*/
public function access($operation, AccountInterface $account = NULL) {
public function access($operation = 'view', AccountInterface $account = NULL) {
if ($operation == 'create') {
return $this->entityManager()
return \Drupal::entityManager()
->getAccessController($this->entityTypeId)
->createAccess($this->bundle(), $account);
}
return $this->entityManager()
return \Drupal::entityManager()
->getAccessController($this->entityTypeId)
->access($this, $operation, $this->activeLangcode, $account);
}
......@@ -567,7 +544,7 @@ public function language() {
$language = NULL;
if ($this->activeLangcode != Language::LANGCODE_DEFAULT) {
if (!isset($this->languages[$this->activeLangcode])) {
$this->languages += $this->languageList(Language::STATE_ALL);
$this->languages += language_list(Language::STATE_ALL);
}
$language = $this->languages[$this->activeLangcode];
}
......@@ -617,7 +594,7 @@ public function onChange($name) {
if ($name == 'langcode') {
$this->setDefaultLangcode();
if (isset($this->translations[$this->defaultLangcode])) {
$message = String::format('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
$message = format_string('A translation already exists for the specified language (@langcode).', array('@langcode' => $this->defaultLangcode));
throw new \InvalidArgumentException($message);
}
$this->updateFieldLangcodes($this->defaultLangcode);
......@@ -666,7 +643,7 @@ public function getTranslation($langcode) {
if (empty($translation)) {
$message = 'Invalid translation language (@langcode) specified.';
throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
}
return $translation;
......@@ -731,14 +708,14 @@ public function hasTranslation($langcode) {
public function addTranslation($langcode, array $values = array()) {
if (!isset($this->languages[$langcode]) || $this->hasTranslation($langcode)) {
$message = 'Invalid translation language (@langcode) specified.';
throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
}
// Instantiate a new empty entity so default values will be populated in the
// specified language.
$entity_type = $this->getEntityType();
$default_values = array($entity_type->getKey('bundle') => $this->bundle, 'langcode' => $langcode);
$entity = $this->entityManager()
$entity = \Drupal::entityManager()
->getStorageController($this->getEntityTypeId())
->create($default_values);
......@@ -776,7 +753,7 @@ public function removeTranslation($langcode) {
}
else {
$message = 'The specified translation (@langcode) cannot be removed.';
throw new \InvalidArgumentException(String::format($message, array('@langcode' => $langcode)));
throw new \InvalidArgumentException(format_string($message, array('@langcode' => $langcode)));
}
}
......@@ -918,7 +895,7 @@ public function __unset($name) {
public function createDuplicate() {
if ($this->translations[$this->activeLangcode]['status'] == static::TRANSLATION_REMOVED) {
$message = 'The entity object refers to a removed translation (@langcode) and cannot be manipulated.';
throw new \InvalidArgumentException(String::format($message, array('@langcode' => $this->activeLangcode)));
throw new \InvalidArgumentException(format_string($message, array('@langcode' => $this->activeLangcode)));
}
$duplicate = clone $this;
......@@ -927,7 +904,8 @@ public function createDuplicate() {
// Check if the entity type supports UUIDs and generate a new one if so.
if ($entity_type->hasKey('uuid')) {
$duplicate->{$entity_type->getKey('uuid')}->value = $this->uuidGenerator()->generate();
// @todo Inject the UUID service into the Entity class once possible.
$duplicate->{$entity_type->getKey('uuid')}->value = \Drupal::service('uuid')->generate();
}
// Check whether the entity type supports revisions and initialize it if so.
......@@ -975,8 +953,9 @@ public function __clone() {
public function label() {
$label = NULL;
$entity_type = $this->getEntityType();
if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) {
$label = call_user_func($label_callback, $this);
// @todo Convert to is_callable() and call_user_func().
if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
$label = $label_callback($this);
}
elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
$label = $this->{$label_key}->value;
......
......@@ -7,14 +7,13 @@
namespace Drupal\Core\Entity;
use Drupal\Core\DependencyInjection\DependencySerialization;
use Drupal\Core\Language\Language;
use Drupal\Core\Session\AccountInterface;
/**
* Defines a base entity class.
*/
abstract class Entity extends DependencySerialization implements EntityInterface {
abstract class Entity implements EntityInterface {
/**
* The language code of the entity's default language.
......@@ -23,20 +22,6 @@ abstract class Entity extends DependencySerialization implements EntityInterface
*/
public $langcode = Language::LANGCODE_NOT_SPECIFIED;
/**
* The entity manager.
*
* @var \Drupal\Core\Entity\EntityManagerInterface
*/
protected $entityManager;
/**
* The UUID generator.
*
* @var \Drupal\Component\Uuid\UuidInterface
*/
protected $uuidGenerator;
/**
* The entity type.
*
......@@ -75,39 +60,6 @@ public function __construct(array $values, $entity_type) {
}
}
/**
* Wraps language_load().
*/
protected function languageLoad($langcode) {
return language_load($langcode);
}
/**
* Returns the entity manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
*/
protected function entityManager() {
if (!$this->entityManager) {
$this->entityManager = \Drupal::entityManager();
}
return $this->entityManager;
}
/**
* Returns the UUID generator.
*
* @return \Drupal\Component\Uuid\UuidInterface
*/
protected function uuidGenerator() {
if (!$this->uuidGenerator) {
$this->uuidGenerator = \Drupal::service('uuid');
}
return $this->uuidGenerator;
}
/**
* {@inheritdoc}
*/
......@@ -134,8 +86,6 @@ public function isNew() {
*/
public function enforceIsNew($value = TRUE) {
$this->enforceIsNew = $value;
return $this;
}
/**
......@@ -158,8 +108,9 @@ public function bundle() {
public function label() {
$label = NULL;
$entity_type = $this->getEntityType();
if (($label_callback = $entity_type->getLabelCallback()) && is_callable($label_callback)) {
$label = call_user_func($label_callback, $this);
// @todo Convert to is_callable() and call_user_func().
if (($label_callback = $entity_type->getLabelCallback()) && function_exists($label_callback)) {
$label = $label_callback($this);
}
elseif (($label_key = $entity_type->getKey('label')) && isset($this->{$label_key})) {
$label = $this->{$label_key};
......@@ -187,7 +138,7 @@ public function urlInfo($rel = 'canonical') {
$bundle = $this->bundle();
// A bundle-specific callback takes precedence over the generic one for
// the entity type.
$bundles = $this->entityManager()->getBundleInfo($this->getEntityTypeId());
$bundles = \Drupal::entityManager()->getBundleInfo($this->getEntityTypeId());
if (isset($bundles[$bundle]['uri_callback'])) {
$uri_callback = $bundles[$bundle]['uri_callback'];
}
......@@ -197,8 +148,9 @@ public function urlInfo($rel = 'canonical') {
// Invoke the callback to get the URI. If there is no callback, use the
// default URI format.
if (isset($uri_callback) && is_callable($uri_callback)) {
$uri = call_user_func($uri_callback, $this);
// @todo Convert to is_callable() and call_user_func().
if (isset($uri_callback) && function_exists($uri_callback)) {
$uri = $uri_callback($this);
}
else {
return array();
......@@ -295,13 +247,13 @@ public function uriRelationships() {
/**
* {@inheritdoc}
*/
public function access($operation, AccountInterface $account = NULL) {
public function access($operation = 'view', AccountInterface $account = NULL) {
if ($operation == 'create') {
return $this->entityManager()
return \Drupal::entityManager()
->getAccessController($this->entityTypeId)
->createAccess($this->bundle(), $account);
}
return $this->entityManager()
return \Drupal::entityManager()
->getAccessController($this->entityTypeId)
->access($this, $operation, Language::LANGCODE_DEFAULT, $account);
}
......@@ -310,7 +262,7 @@ public function access($operation, AccountInterface $account = NULL) {
* {@inheritdoc}
*/
public function language() {
$language = $this->languageLoad($this->langcode);
$language = language_load($this->langcode);
if (!$language) {
// Make sure we return a proper language object.
$language = new Language(array('id' => Language::LANGCODE_NOT_SPECIFIED));
......@@ -322,7 +274,7 @@ public function language() {
* {@inheritdoc}
*/
public function save() {
return $this->entityManager()->getStorageController($this->entityTypeId)->save($this);
return \Drupal::entityManager()->getStorageController($this->entityTypeId)->save($this);
}
/**
......@@ -330,7 +282,7 @@ public function save() {
*/
public function delete() {
if (!$this->isNew()) {
$this->entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this));
\Drupal::entityManager()->getStorageController($this->entityTypeId)->delete(array($this->id() => $this));
}
}
......@@ -344,7 +296,8 @@ public function createDuplicate() {
// Check if the entity type supports UUIDs and generate a new one if so.
if ($entity_type->hasKey('uuid')) {
$duplicate->{$entity_type->getKey('uuid')} = $this->uuidGenerator()->generate();
// @todo Inject the UUID service into the Entity class once possible.
$duplicate->{$entity_type->getKey('uuid')} = \Drupal::service('uuid')->generate();
}
return $duplicate;
}
......@@ -353,7 +306,7 @@ public function createDuplicate() {
* {@inheritdoc}
*/
public function getEntityType() {
return $this->entityManager()->getDefinition($this->getEntityTypeId());
return \Drupal::entityManager()->getDefinition($this->getEntityTypeId());
}
/**
......@@ -391,7 +344,6 @@ public static function preDelete(EntityStorageControllerInterface $storage_contr
* {@inheritdoc}
*/
public static function postDelete(EntityStorageControllerInterface $storage_controller, array $entities) {
/** @var self[] $entities */
foreach ($entities as $entity) {
$entity->onSaveOrDelete();
}
......@@ -423,8 +375,8 @@ protected function onSaveOrDelete() {
}
foreach ($referenced_entities as $entity_type => $entities) {
if ($this->entityManager()->hasController($entity_type, 'view_builder')) {
$this->entityManager()->getViewBuilder($entity_type)->resetCache($entities);
if (\Drupal::entityManager()->hasController($entity_type, 'view_builder')) {
\Drupal::entityManager()->getViewBuilder($entity_type)->resetCache($entities);
}
}
}
......@@ -442,4 +394,14 @@ protected function urlGenerator() {
return $this->urlGenerator;
}
/**
* {@inheritdoc}
*/
public function __sleep() {
// Don't serialize the url generator.
$this->urlGenerator = NULL;
return array_keys(get_object_vars($this));
}
}
......@@ -65,8 +65,6 @@ public function isNew();
* (optional) Whether the entity should be forced to be new. Defaults to
* TRUE.
*
* @return self
*
* @see \Drupal\Core\Entity\EntityInterface::isNew()
*/
public function enforceIsNew($value = TRUE);
......
......@@ -63,7 +63,7 @@ public function set($property_name, $value, $notify = TRUE);
* @param bool $include_computed
* If set to TRUE, computed properties are included. Defaults to FALSE.
*
* @return \Drupal\Core\TypedData\TypedDataInterface[]
* @return array
* An array of property objects implementing the TypedDataInterface, keyed
* by property name.
*/
......
......@@ -199,7 +199,7 @@ function _block_get_renderable_region($list = array()) {
$settings = $block->get('settings');
if ($not_cacheable || in_array($settings['cache'], array(DRUPAL_NO_CACHE, DRUPAL_CACHE_CUSTOM))) {
// Non-cached blocks get built immediately.
if ($block->access('view')) {
if ($block->access()) {
$build[$key] = entity_view($block, 'block');
}
}
......@@ -378,7 +378,7 @@ function block_load($entity_id) {
function _block_get_renderable_block($element) {
$block = $element['#block'];
// Don't bother to build blocks that aren't accessible.
if ($element['#access'] = $block->access('view')) {
if ($element['#access'] = $block->access()) {
$element += entity_view($block, 'block');
}
return $element;
......
......@@ -10,7 +10,6 @@
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\block\BlockPluginBag;
use Drupal\block\BlockInterface;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
/**
......@@ -149,7 +148,7 @@ public function getExportProperties() {
/**
* Sorts active blocks by weight; sorts inactive blocks by name.
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
public static function sort($a, $b) {
// Separate enabled from disabled.
$status = $b->get('status') - $a->get('status');
if ($status) {
......
......@@ -97,4 +97,14 @@ public function testStorageControllerMethods() {
}
}
/**
* Tests getOriginalId() and setOriginalId().
*/
protected function testGetOriginalId() {
$entity = $this->storage->create(array());
$id = $this->randomName();
$this->assertIdentical(spl_object_hash($entity->setOriginalId($id)), spl_object_hash($entity));
$this->assertIdentical($entity->getOriginalId(), $id);
}
}
......@@ -9,7 +9,6 @@
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\config_test\ConfigTestInterface;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Defines the ConfigTest configuration entity.
......@@ -94,7 +93,7 @@ public function getExportProperties() {
/**
* Overrides \Drupal\Core\Config\Entity\ConfigEntityBase::sort().
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
public static function sort($a, $b) {
\Drupal::state()->set('config_entity_sort', TRUE);
return parent::sort($a, $b);
}
......
......@@ -8,7 +8,6 @@
namespace Drupal\entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
/**
* Base class for config entity types that hold settings for form and view modes.
......@@ -61,9 +60,7 @@ abstract class EntityDisplayModeBase extends ConfigEntityBase implements EntityD
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
/** @var \Drupal\entity\EntityDisplayModeInterface $a */
/** @var \Drupal\entity\EntityDisplayModeInterface $b */
public static function sort($a, $b) {
// Sort by the type of entity the view mode is used for.
$a_type = $a->getTargetType();
$b_type = $b->getTargetType();
......
......@@ -8,7 +8,6 @@
namespace Drupal\search\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
use Drupal\Core\Entity\EntityStorageControllerInterface;
use Drupal\Component\Plugin\ConfigurablePluginInterface;
......@@ -214,7 +213,7 @@ public static function postDelete(EntityStorageControllerInterface $storage_cont
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
public static function sort($a, $b) {
/** @var $a \Drupal\search\SearchPageInterface */
/** @var $b \Drupal\search\SearchPageInterface */
$a_status = (int) $a->status();
......
......@@ -8,7 +8,6 @@
namespace Drupal\system\Entity;
use Drupal\Core\Config\Entity\ConfigEntityBase;
use Drupal\Core\Config\Entity\ConfigEntityInterface;
use Drupal\Core\Config\Entity\EntityWithPluginBagInterface;
use Drupal\system\ActionConfigEntityInterface;
use Drupal\Core\Action\ActionBag;
......@@ -132,9 +131,7 @@ public function getType() {
/**
* {@inheritdoc}
*/
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
/** @var \Drupal\system\ActionConfigEntityInterface $a */
/** @var \Drupal\system\ActionConfigEntityInterface $b */
public static function sort($a, $b) {
$a_type = $a->getType();
$b_type = $b->getType();
if ($a_type != $b_type) {
......
<?php
/**
* @file
* Contains \Drupal\system\Tests\Entity\EntityLabelTest.
*/
namespace Drupal\system\Tests\Entity;
/**
* Tests entity properties.
*/
class EntityLabelTest extends EntityUnitTestBase {
public static function getInfo() {
return array(
'name' => 'Entity label',
'description' => 'Tests entity labels.',
'group' => 'Entity API',
);
}
/**
* Tests label key and label callback of an entity.
*/
function testEntityLabel() {
$entity_types = array(
'entity_test_no_label',
'entity_test_label',
'entity_test_label_callback',
);
$values = array(
'name' => $this->randomName(),
);
foreach ($entity_types as $entity_type) {
$entity = entity_create($entity_type, $values);
$label = $entity->label();
switch ($entity_type) {
case 'entity_test_no_label':
$this->assertFalse($label, 'Entity with no label property or callback returned FALSE.');
break;
case 'entity_test_label':
$this->assertEqual($label, $entity->name->value, 'Entity with label key returned correct label.');
break;
case 'entity_test_label_callback':
$this->assertEqual($label, 'label callback ' . $entity->name->value, 'Entity with label callback returned correct label.');
break;
}
}
}
}