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 / Message / MessageResourceTestBase.php
index 3f1cab9b91a4404f8d2f2ef5303a4549371452e6..2cd00a7cb5e0b8af090a4045361bdc5f8016c165 100644 (file)
 
 namespace Drupal\Tests\rest\Functional\EntityResource\Message;
 
-use Drupal\contact\Entity\ContactForm;
-use Drupal\contact\Entity\Message;
-use Drupal\Core\Url;
-use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
-use Symfony\Component\Routing\Exception\RouteNotFoundException;
+@trigger_error('The ' . __NAMESPACE__ . '\MessageResourceTestBase is deprecated in Drupal 8.6.x and will be removed before Drupal 9.0.0. Instead, use Drupal\Tests\contact\Functional\Rest\MessageResourceTestBase. See https://www.drupal.org/node/2971931.', E_USER_DEPRECATED);
 
-abstract class MessageResourceTestBase extends EntityResourceTestBase {
-
-  /**
-   * {@inheritdoc}
-   */
-  public static $modules = ['contact'];
-
-  /**
-   * {@inheritdoc}
-   */
-  protected static $entityTypeId = 'contact_message';
-
-  /**
-   * {@inheritdoc}
-   */
-  protected static $labelFieldName = 'subject';
-
-  /**
-   * The Message entity.
-   *
-   * @var \Drupal\contact\MessageInterface
-   */
-  protected $entity;
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function setUpAuthorization($method) {
-    $this->grantPermissionsToTestedRole(['access site-wide contact form']);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function createEntity() {
-    if (!ContactForm::load('camelids')) {
-      // Create a "Camelids" contact form.
-      ContactForm::create([
-        'id' => 'camelids',
-        'label' => 'Llama',
-        'message' => 'Let us know what you think about llamas',
-        'reply' => 'Llamas are indeed awesome!',
-        'recipients' => [
-          'llama@example.com',
-          'contact@example.com',
-        ],
-      ])->save();
-    }
-
-    $message = Message::create([
-      'contact_form' => 'camelids',
-      'subject' => 'Llama Gabilondo',
-      'message' => 'Llamas are awesome!',
-    ]);
-    $message->save();
-
-    return $message;
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getNormalizedPostEntity() {
-    return [
-      'subject' => [
-        [
-          'value' => 'Dramallama',
-        ],
-      ],
-      'contact_form' => [
-        [
-          'target_id' => 'camelids',
-        ],
-      ],
-      'message' => [
-        [
-          'value' => 'http://www.urbandictionary.com/define.php?term=drama%20llama',
-        ],
-      ],
-    ];
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedNormalizedEntity() {
-    throw new \Exception('Not yet supported.');
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  protected function getExpectedUnauthorizedAccessMessage($method) {
-    if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
-      return parent::getExpectedUnauthorizedAccessMessage($method);
-    }
-
-    if ($method === 'POST') {
-      return "The 'access site-wide contact form' permission is required.";
-    }
-    return parent::getExpectedUnauthorizedAccessMessage($method);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testGet() {
-    // Contact Message entities are not stored, so they cannot be retrieved.
-    $this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.GET" does not exist.');
-
-    $this->provisionEntityResource();
-    Url::fromRoute('rest.entity.contact_message.GET')->toString(TRUE);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testPatch() {
-    // Contact Message entities are not stored, so they cannot be modified.
-    $this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.PATCH" does not exist.');
-
-    $this->provisionEntityResource();
-    Url::fromRoute('rest.entity.contact_message.PATCH')->toString(TRUE);
-  }
-
-  /**
-   * {@inheritdoc}
-   */
-  public function testDelete() {
-    // Contact Message entities are not stored, so they cannot be deleted.
-    $this->setExpectedException(RouteNotFoundException::class, 'Route "rest.entity.contact_message.DELETE" does not exist.');
-
-    $this->provisionEntityResource();
-    Url::fromRoute('rest.entity.contact_message.DELETE')->toString(TRUE);
-  }
+use Drupal\Tests\contact\Functional\Rest\MessageResourceTestBase as MessageResourceTestBaseReal;
 
+/**
+ * @deprecated in Drupal 8.6.x. Will be removed before Drupal 9.0.0. Use
+ *   Drupal\Tests\contact\Functional\Rest\MessageResourceTestBase instead.
+ *
+ * @see https://www.drupal.org/node/2971931
+ */
+abstract class MessageResourceTestBase extends MessageResourceTestBaseReal {
 }