namespace Drupal\Tests\rest\Functional\EntityResource\Term;
+use Drupal\Core\Cache\Cache;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
case 'GET':
$this->grantPermissionsToTestedRole(['access content']);
break;
+
case 'POST':
+ $this->grantPermissionsToTestedRole(['create terms in camelids']);
+ break;
+
case 'PATCH':
- case 'DELETE':
// Grant the 'create url aliases' permission to test the case when
// the path field is accessible, see
// \Drupal\Tests\rest\Functional\EntityResource\Node\NodeResourceTestBase
// for a negative test.
- // @todo Update once https://www.drupal.org/node/2824408 lands.
- $this->grantPermissionsToTestedRole(['administer taxonomy', 'create url aliases']);
+ $this->grantPermissionsToTestedRole(['edit terms in camelids', 'create url aliases']);
+ break;
+
+ case 'DELETE':
+ $this->grantPermissionsToTestedRole(['delete terms in camelids']);
break;
+
}
}
// Create a "Llama" taxonomy term.
$term = Term::create(['vid' => $vocabulary->id()])
->setName('Llama')
+ ->setDescription("It is a little known fact that llamas cannot count higher than seven.")
->setChangedTime(123456789)
->set('path', '/llama');
$term->save();
],
'description' => [
[
- 'value' => NULL,
+ 'value' => 'It is a little known fact that llamas cannot count higher than seven.',
'format' => NULL,
+ 'processed' => "<p>It is a little known fact that llamas cannot count higher than seven.</p>\n",
],
],
'parent' => [],
case 'GET':
return "The 'access content' permission is required.";
case 'POST':
- return "The 'administer taxonomy' permission is required.";
+ return "The following permissions are required: 'create terms in camelids' OR 'administer taxonomy'.";
case 'PATCH':
return "The following permissions are required: 'edit terms in camelids' OR 'administer taxonomy'.";
case 'DELETE':
$response = $this->request('GET', $url, $this->getAuthenticationRequestOptions('GET'));
$normalization = $this->serializer->decode((string) $response->getBody(), static::$format);
- // @todo In https://www.drupal.org/node/2824851, we will be able to stop
- // unsetting these fields from the normalization, because
- // EntityResource::patch() will ignore any fields that are sent that
- // match the current value (and obviously we're sending the current
- // value).
- $normalization = $this->removeFieldsFromNormalization($normalization, [
- 'changed',
- ]);
-
// Change term's path alias.
$normalization['path'][0]['alias'] .= 's-rule-the-world';
$this->assertSame($normalization['path'], $updated_normalization['path']);
}
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExpectedCacheTags() {
+ return Cache::mergeTags(parent::getExpectedCacheTags(), ['config:filter.format.plain_text', 'config:filter.settings']);
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function getExpectedCacheContexts() {
+ return Cache::mergeContexts(['url.site'], $this->container->getParameter('renderer.config')['required_cache_contexts']);
+ }
+
}