.../Tests/CustomBlockCacheTagsTest.php | 4 ++-- .../Drupal/comment/Tests/CommentCacheTagsTest.php | 4 ++-- .../lib/Drupal/node/Tests/NodeCacheTagsTest.php | 6 ++--- .../Tests/Entity/EntityCacheTagsTestBase.php | 23 ++++---------------- .../Entity/EntityWithUriCacheTagsTestBase.php | 4 ++-- .../Drupal/taxonomy/Tests/TermCacheTagsTest.php | 4 ++-- .../lib/Drupal/user/Tests/UserCacheTagsTest.php | 4 ++-- 7 files changed, 17 insertions(+), 32 deletions(-) diff --git a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCacheTagsTest.php b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCacheTagsTest.php index 6270631..ccd51dd 100644 --- a/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCacheTagsTest.php +++ b/core/modules/block/custom_block/lib/Drupal/custom_block/Tests/CustomBlockCacheTagsTest.php @@ -23,13 +23,13 @@ class CustomBlockCacheTagsTest extends EntityCacheTagsTestBase { * {@inheritdoc} */ public static function getInfo() { - return static::generateStandardizedInfo('Custom Block', 'Custom Block'); + return parent::generateStandardizedInfo('Custom Block', 'Custom Block'); } /** * {@inheritdoc} */ - protected static function createEntity() { + protected function createEntity() { // Create a "Llama" custom block. $custom_block = entity_create('custom_block', array( 'info' => 'Llama', diff --git a/core/modules/comment/lib/Drupal/comment/Tests/CommentCacheTagsTest.php b/core/modules/comment/lib/Drupal/comment/Tests/CommentCacheTagsTest.php index d42ec20..07cac6e 100644 --- a/core/modules/comment/lib/Drupal/comment/Tests/CommentCacheTagsTest.php +++ b/core/modules/comment/lib/Drupal/comment/Tests/CommentCacheTagsTest.php @@ -23,7 +23,7 @@ class CommentCacheTagsTest extends EntityWithUriCacheTagsTestBase { * {@inheritdoc} */ public static function getInfo() { - return static::generateStandardizedInfo('Comment', 'Comment'); + return parent::generateStandardizedInfo('Comment', 'Comment'); } /** @@ -42,7 +42,7 @@ public function setUp() { /** * {@inheritdoc} */ - protected static function createEntity() { + protected function createEntity() { // Create a "bar" bundle for the "entity_test" entity type and create. $bundle = 'bar'; entity_test_create_bundle($bundle, NULL, 'entity_test'); diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php index 514c2d9..0d3dc2a 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeCacheTagsTest.php @@ -24,7 +24,7 @@ class NodeCacheTagsTest extends EntityWithUriCacheTagsTestBase { * {@inheritdoc} */ public static function getInfo() { - return static::generateStandardizedInfo('Node', 'Node'); + return parent::generateStandardizedInfo('Node', 'Node'); } /** @@ -43,7 +43,7 @@ public function setUp() { /** * {@inheritdoc} */ - protected static function createEntity() { + protected function createEntity() { // Create a "Camelids" node type. entity_create('node_type', array( 'name' => 'Camelids', @@ -62,7 +62,7 @@ protected static function createEntity() { /** * {@inheritdoc} */ - protected static function getAdditionalCacheTagsForEntity(EntityInterface $node) { + protected function getAdditionalCacheTagsForEntity(EntityInterface $node) { return array('user:' . $node->getOwnerId()); } diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCacheTagsTestBase.php index d426390..f1a0c84 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityCacheTagsTestBase.php @@ -58,7 +58,7 @@ public function setUp() { $user_role->save(); // Create an entity. - $this->entity = static::createEntity(); + $this->entity = $this->createEntity(); // If this is a fieldable entity, then add a configurable field. We will use // this configurable field in later tests to ensure that modifications to @@ -93,7 +93,7 @@ public function setUp() { list( $this->referencing_entity, $this->non_referencing_entity, - ) = static::createReferenceTestEntities($this->entity); + ) = $this->createReferenceTestEntities($this->entity); } /** @@ -119,36 +119,21 @@ protected static function generateStandardizedInfo($entity_type_label, $group) { /** * Creates the entity to be tested. * - * This is a static method to guarantee that subclasses that implement it - * don't set additional properties on the object: it ensures a clear, strict - * contract. - * * @return \Drupal\Core\Entity\EntityInterface * The entity to be tested. */ - protected static function createEntity() { - // PHP doesn't allow us to declare this method as abstract protected static, - // so we simply throw an exception here if this has not been implemented by - // a child class. - throw new \RuntimeException(String::format('@class must implement \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createEntity().', array( - '@class' => get_called_class(), - ))); - } + abstract protected function createEntity(); /** * Creates a referencing and a non-referencing entity for testing purposes. * - * This is a static method to guarantee that subclasses that override it - * don't set additional properties on the object: it ensures a clear, strict - * contract. - * * @param \Drupal\Core\Entity\EntityInterface $referenced_entity * The entity that the referencing entity should reference. * * @return \Drupal\Core\Entity\EntityInterface[] * An array containing a referencing entity and a non-referencing entity. */ - protected static function createReferenceTestEntities($referenced_entity) { + protected function createReferenceTestEntities($referenced_entity) { // All referencing entities should be of the type 'entity_test'. $entity_type = 'entity_test'; diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityWithUriCacheTagsTestBase.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityWithUriCacheTagsTestBase.php index a979174..de46515 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityWithUriCacheTagsTestBase.php +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityWithUriCacheTagsTestBase.php @@ -26,7 +26,7 @@ * * @see \Drupal\system\Tests\Entity\EntityCacheTagsTestBase::createEntity() */ - protected static function getAdditionalCacheTagsForEntity(EntityInterface $entity) { + protected function getAdditionalCacheTagsForEntity(EntityInterface $entity) { return array(); } @@ -58,7 +58,7 @@ public function testEntityUri() { if (\Drupal::entityManager()->getDefinition($entity_type)->isRenderCacheable()) { $cid = 'entity_view:' . $entity_type . ':' . $this->entity->id() . ':full:stark:r.anonymous'; $cache_entry = \Drupal::cache()->get($cid); - $expected_cache_tags = array_merge(array($view_cache_tag, $cache_tag), static::getAdditionalCacheTagsForEntity($this->entity)); + $expected_cache_tags = array_merge(array($view_cache_tag, $cache_tag), $this->getAdditionalCacheTagsForEntity($this->entity)); $this->assertIdentical($cache_entry->tags, $expected_cache_tags); } diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermCacheTagsTest.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermCacheTagsTest.php index 6d7b649..6cd6457 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermCacheTagsTest.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Tests/TermCacheTagsTest.php @@ -23,13 +23,13 @@ class TermCacheTagsTest extends EntityWithUriCacheTagsTestBase { * {@inheritdoc} */ public static function getInfo() { - return static::generateStandardizedInfo('Taxonomy term', 'Taxonomy'); + return parent::generateStandardizedInfo('Taxonomy term', 'Taxonomy'); } /** * {@inheritdoc} */ - protected static function createEntity() { + protected function createEntity() { // Create a "Camelids" vocabulary. $vocabulary = entity_create('taxonomy_vocabulary', array( 'name' => 'Camelids', diff --git a/core/modules/user/lib/Drupal/user/Tests/UserCacheTagsTest.php b/core/modules/user/lib/Drupal/user/Tests/UserCacheTagsTest.php index 8db5b7b..a80be50 100644 --- a/core/modules/user/lib/Drupal/user/Tests/UserCacheTagsTest.php +++ b/core/modules/user/lib/Drupal/user/Tests/UserCacheTagsTest.php @@ -23,7 +23,7 @@ class UserCacheTagsTest extends EntityWithUriCacheTagsTestBase { * {@inheritdoc} */ public static function getInfo() { - return static::generateStandardizedInfo('User', 'User'); + return parent::generateStandardizedInfo('User', 'User'); } /** @@ -42,7 +42,7 @@ public function setUp() { /** * {@inheritdoc} */ - protected static function createEntity() { + protected function createEntity() { // Create a "Llama" user. $user = entity_create('user', array( 'name' => 'Llama',