3 namespace Drupal\Tests\rest\Functional\EntityResource\Feed;
5 use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
6 use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
7 use Drupal\aggregator\Entity\Feed;
9 abstract class FeedResourceTestBase extends EntityResourceTestBase {
11 use BcTimestampNormalizerUnixTestTrait;
16 public static $modules = ['aggregator'];
21 public static $entityTypeId = 'aggregator_feed';
26 protected static $patchProtectedFieldNames = [];
31 protected static $uniqueFieldNames = ['url'];
36 protected function setUpAuthorization($method) {
39 $this->grantPermissionsToTestedRole(['access news feeds']);
44 $this->grantPermissionsToTestedRole(['administer news feeds']);
52 public function createEntity() {
53 $feed = Feed::create();
55 ->set('uuid', 'abcdefg')
57 ->setUrl('http://example.com/rss.xml')
58 ->setDescription('Feed Resource Test 1')
60 ->setLastCheckedTime(123456789)
61 ->setQueuedTime(123456789)
62 ->setWebsiteUrl('http://example.com')
63 ->setImage('http://example.com/feed_logo')
66 ->setLastModified(123456789)
75 protected function getExpectedNormalizedEntity() {
94 'value' => 'http://example.com/rss.xml'
108 $this->formatExpectedTimestampItemValues(123456789),
111 $this->formatExpectedTimestampItemValues(123456789),
115 'value' => 'http://example.com'
120 'value' => 'Feed Resource Test 1'
125 'value' => 'http://example.com/feed_logo'
139 $this->formatExpectedTimestampItemValues(123456789),
147 protected function getNormalizedPostEntity() {
151 'value' => 'Feed Resource Post Test'
156 'value' => 'http://example.com/feed'
166 'value' => 'Feed Resource Post Test Description'
175 protected function getExpectedUnauthorizedAccessMessage($method) {
176 if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
177 return parent::getExpectedUnauthorizedAccessMessage($method);
182 return "The 'access news feeds' permission is required.";
186 return "The 'administer news feeds' permission is required.";
188 return parent::getExpectedUnauthorizedAccessMessage($method);