Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / rest / tests / src / Functional / EntityResource / BlockContent / BlockContentResourceTestBase.php
index 57668179404192b9af4acafdc20ff1f9e8834e91..de452a87e27e4159f3e4908cb4295753188cf68a 100644 (file)
 
 namespace Drupal\Tests\rest\Functional\EntityResource\BlockContent;
 
-use Drupal\block_content\Entity\BlockContent;
-use Drupal\block_content\Entity\BlockContentType;
-use Drupal\Core\Cache\Cache;
-use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
-use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
+@trigger_error('The ' . __NAMESPACE__ . '\BlockContentResourceTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\block_content\Functional\Rest\BlockContentResourceTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED);
+
+use Drupal\Tests\block_content\Functional\Rest\BlockContentResourceTestBase as BlockContentResourceTestBaseReal;
 
 /**
- * ResourceTestBase for BlockContent entity.
+ * @deprecated in Drupal 8.6.x. Will be removed before Drupal 9.0.0. Use
+ *   Drupal\Tests\block_content\Functional\Rest\BlockContentResourceTestBase instead.
+ *
+ * @see https://www.drupal.org/node/2971931
  */
-abstract class BlockContentResourceTestBase extends EntityResourceTestBase {
-
-  use BcTimestampNormalizerUnixTestTrait;
-
-  /**
-   * {@inheritdoc}
-   */
-  public static $modules = ['block_content'];
-
-  /**
-   * {@inheritdoc}
-   */
-  protected static $entityTypeId = 'block_content';
-
-  /**
-   * {@inheritdoc}
-   */
-  protected static $patchProtectedFieldNames = [
-    'changed',
-  ];
-
-  /**
-   * @var \Drupal\block_content\BlockContentInterface
-   */
-  protected $entity;
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function setUpAuthorization($method) {
-    $this->grantPermissionsToTestedRole(['administer blocks']);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function createEntity() {
-    if (!BlockContentType::load('basic')) {
-      $block_content_type = BlockContentType::create([
-        'id' => 'basic',
-        'label' => 'basic',
-        'revision' => TRUE,
-      ]);
-      $block_content_type->save();
-      block_content_add_body_field($block_content_type->id());
-    }
-
-    // Create a "Llama" custom block.
-    $block_content = BlockContent::create([
-      'info' => 'Llama',
-      'type' => 'basic',
-      'body' => [
-        'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
-        'format' => 'plain_text',
-      ],
-    ])
-      ->setPublished(FALSE);
-    $block_content->save();
-    return $block_content;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedNormalizedEntity() {
-    return [
-      'id' => [
-        [
-          'value' => 1,
-        ],
-      ],
-      'uuid' => [
-        [
-          'value' => $this->entity->uuid(),
-        ],
-      ],
-      'langcode' => [
-        [
-          'value' => 'en',
-        ],
-      ],
-      'type' => [
-        [
-          'target_id' => 'basic',
-          'target_type' => 'block_content_type',
-          'target_uuid' => BlockContentType::load('basic')->uuid(),
-        ],
-      ],
-      'info' => [
-        [
-          'value' => 'Llama',
-        ],
-      ],
-      'revision_log' => [],
-      'changed' => [
-        $this->formatExpectedTimestampItemValues($this->entity->getChangedTime()),
-      ],
-      'revision_id' => [
-        [
-          'value' => 1,
-        ],
-      ],
-      'revision_created' => [
-        $this->formatExpectedTimestampItemValues((int) $this->entity->getRevisionCreationTime()),
-      ],
-      'revision_user' => [],
-      'revision_translation_affected' => [
-        [
-          'value' => TRUE,
-        ],
-      ],
-      'default_langcode' => [
-        [
-          'value' => TRUE,
-        ],
-      ],
-      'body' => [
-        [
-          'value' => 'The name "llama" was adopted by European settlers from native Peruvians.',
-          'format' => 'plain_text',
-          'summary' => NULL,
-          'processed' => "<p>The name &quot;llama&quot; was adopted by European settlers from native Peruvians.</p>\n",
-        ],
-      ],
-      'status' => [
-        [
-          'value' => FALSE,
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getNormalizedPostEntity() {
-    return [
-      'type' => [
-        [
-          'target_id' => 'basic',
-        ],
-      ],
-      'info' => [
-        [
-          'value' => 'Dramallama',
-        ],
-      ],
-    ];
-  }
-
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
-    if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
-      return parent::getExpectedUnauthorizedAccessMessage($method);
-    }
-
-    return parent::getExpectedUnauthorizedAccessMessage($method);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedUnauthorizedAccessCacheability() {
-    // @see \Drupal\block_content\BlockContentAccessControlHandler()
-    return parent::getExpectedUnauthorizedAccessCacheability()
-      ->addCacheTags(['block_content:1']);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedCacheTags() {
-    return Cache::mergeTags(parent::getExpectedCacheTags(), ['config:filter.format.plain_text']);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedCacheContexts() {
-    return Cache::mergeContexts(['url.site'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
-  }
-
+abstract class BlockContentResourceTestBase extends BlockContentResourceTestBaseReal {
 }