3 namespace Drupal\Tests\rest\Functional\EntityResource\Item;
5 use Drupal\aggregator\Entity\Feed;
6 use Drupal\aggregator\Entity\Item;
7 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
10 * ResourceTestBase for Item entity.
12 abstract class ItemResourceTestBase extends EntityResourceTestBase {
17 public static $modules = ['aggregator'];
22 protected static $entityTypeId = 'aggregator_item';
27 protected static $patchProtectedFieldNames = [];
32 * @var \Drupal\aggregator\ItemInterface
39 protected function setUpAuthorization($method) {
42 $this->grantPermissionsToTestedRole(['access news feeds']);
48 $this->grantPermissionsToTestedRole(['administer news feeds']);
56 protected function createEntity() {
57 // Create a "Camelids" feed.
58 $feed = Feed::create([
59 'title' => 'Camelids',
60 'url' => 'https://groups.drupal.org/not_used/167169',
62 'checked' => 1389919932,
63 'description' => 'Drupal Core Group feed',
67 // Create a "Llama" item.
68 $item = Item::create();
69 $item->setTitle('Llama')
70 ->setFeedId($feed->id())
71 ->setLink('https://www.drupal.org/')
72 ->setPostedTime(123456789)
81 protected function getExpectedNormalizedEntity() {
82 $feed = Feed::load($this->entity->getFeedId());
98 'target_type' => 'aggregator_feed',
99 'target_uuid' => $feed->uuid(),
100 'url' => base_path() . 'aggregator/sources/1',
110 'value' => 'https://www.drupal.org/',
117 'value' => 123456789,
127 protected function getNormalizedPostEntity() {
141 'value' => 'https://www.drupal.org/',
150 protected function getExpectedCacheContexts() {
151 // @see ::createEntity()
152 return ['user.permissions'];
158 protected function getExpectedUnauthorizedAccessMessage($method) {
159 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
160 return parent::getExpectedUnauthorizedAccessMessage($method);
165 return "The 'access news feeds' permission is required.";
170 return "The 'administer news feeds' permission is required.";
173 return parent::getExpectedUnauthorizedAccessMessage($method);