Skip to content
Snippets Groups Projects
Commit 4ffb98e3 authored by cilefen's avatar cilefen
Browse files

Issue #2843997 by Sam152: Add missing test coverage for content edit tab labels

parent 41eda3b8
No related branches found
No related tags found
No related merge requests found
......@@ -84,7 +84,6 @@ public function getTitle() {
return parent::getTitle();
}
// @todo https://www.drupal.org/node/2779933 write a test for this.
return $this->moderationInfo->isLiveRevision($this->entity)
? $this->t('New draft')
: $this->t('Edit draft');
......@@ -94,7 +93,6 @@ public function getTitle() {
* {@inheritdoc}
*/
public function getCacheTags() {
// @todo https://www.drupal.org/node/2779933 write a test for this.
$tags = parent::getCacheTags();
// Tab changes if node or node-type is modified.
if ($this->entity) {
......
......@@ -42,7 +42,9 @@ protected function setUp() {
$this->drupalPlaceBlock('local_tasks_block', ['id' => 'tabs_block']);
$this->drupalLogin($this->createUser(['bypass node access']));
$node_type = $this->createContentType();
$node_type = $this->createContentType([
'type' => 'test_content_type',
]);
// Now enable moderation for subsequent nodes.
$workflow = Workflow::load('editorial');
......@@ -59,20 +61,35 @@ protected function setUp() {
* Tests local tasks behave with content_moderation enabled.
*/
public function testLocalTasks() {
// The default state is a draft.
$this->drupalGet(sprintf('node/%s', $this->testNode->id()));
$this->assertTasks('Edit draft');
// When published as the live revision, the label changes.
$this->testNode->moderation_state = 'published';
$this->testNode->save();
$this->drupalGet(sprintf('node/%s', $this->testNode->id()));
$this->assertTasks(TRUE);
$this->assertTasks('New draft');
$tags = $this->drupalGetHeader('X-Drupal-Cache-Tags');
$this->assertContains('node:1', $tags);
$this->assertContains('node_type:test_content_type', $tags);
// Without an upcast node, the state cannot be determined.
$this->clickLink('Task Without Upcast Node');
$this->assertTasks(FALSE);
$this->assertTasks('Edit');
}
/**
* Assert the correct tasks appear.
*
* @param string $edit_tab_label
* The edit tab label to assert.
*/
protected function assertTasks($with_upcast_node) {
protected function assertTasks($edit_tab_label) {
$this->assertSession()->linkExists('View');
$this->assertSession()->linkExists('Task Without Upcast Node');
$this->assertSession()->linkExists($with_upcast_node ? 'Edit draft' : 'Edit');
$this->assertSession()->linkExists($edit_tab_label);
$this->assertSession()->linkExists('Delete');
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment