// Create a new transition.
$this->
submitForm(['id' => 'save_and_publish', 'label' => 'Save and publish', 'from[published]' => 'published', 'to' => 'published'
], 'Save'
);
$this->
assertSession()->
pageTextContains('Created Save and publish transition.'
);
// Edit the new transition and try to add an existing transition.
$this->
clickLink('Edit', 4
);
$this->
submitForm(['from[draft]' => 'draft'
], 'Save'
);
$this->
assertSession()->
pageTextContains('The transition from Draft to Live already exists.'
);
// Delete the transition.
$workflow =
$workflow_storage->
loadUnchanged('test'
);
$this->
assertTrue($workflow->
getTypePlugin()->
hasTransitionFromStateToState('published', 'published'
), 'Can transition from published to published'
);
$this->
clickLink('Delete'
);
$this->
assertSession()->
pageTextContains('Are you sure you want to delete Save and publish from Test?'
);
$this->
submitForm([], 'Delete'
);
$workflow =
$workflow_storage->
loadUnchanged('test'
);
$this->
assertFalse($workflow->
getTypePlugin()->
hasTransitionFromStateToState('published', 'published'
), 'Cannot transition from published to published'
);
// Try creating a duplicate state.
$this->
drupalGet('admin/config/workflow/workflows/manage/test'
);
$this->
clickLink('Add a new state'
);
$this->
submitForm(['label' => 'Draft', 'id' => 'draft'
], 'Save'
);
$this->
assertSession()->
pageTextContains('The machine-readable name is already in use. It must be unique.'
);