function TMGMTUiTest::testJobItemDelete in Translation Management Tool 8
Test the deletion and abortion of job item.
@todo There will be some overlap with Aborting items & testAbortJob.
File
- tests/
src/ Functional/ TMGMTUiTest.php, line 756
Class
- TMGMTUiTest
- Verifies basic functionality of the user interface
Namespace
Drupal\Tests\tmgmt\FunctionalCode
function testJobItemDelete() {
$this
->loginAsAdmin();
// Create a translator.
$translator = $this
->createTranslator();
// Create a job and attach to the translator.
$job = $this
->createJob();
$job->translator = $translator;
$job->settings = array();
$job
->save();
$job
->setState(Job::STATE_ACTIVE);
// Add item to the job.
$item = $job
->addItem('test_source', 'test', 1);
$item
->setState(JobItem::STATE_ACTIVE);
// Check that there is no delete link on item review form.
$this
->drupalGet('admin/tmgmt/items/' . $item
->id());
$this
->assertNoFieldById('edit-delete', NULL, 'There is no delete button.');
$this
->drupalGet('admin/tmgmt/jobs/' . $job
->id());
// Check that there is no delete link.
$this
->assertNoLink('Delete');
// Check for abort link.
$this
->assertLink('Abort');
$this
->clickLink('Abort');
$this
->assertText(t('Are you sure you want to abort the job item test_source:test:1?'));
// Check if cancel button is present or not.
$this
->assertLink('Cancel');
// Abort the job item.
$this
->drupalPostForm(NULL, [], t('Confirm'));
// Reload job and check its state and state of its item.
\Drupal::entityTypeManager()
->getStorage('tmgmt_job')
->resetCache();
$job = Job::load($job
->id());
$this
->assertTrue($job
->isFinished());
$items = $job
->getItems();
$item = reset($items);
$this
->assertTrue($item
->isAborted());
// Check that there is no delete button on item review form.
$this
->drupalGet('admin/tmgmt/items/' . $item
->id());
$this
->assertNoFieldById('edit-delete', NULL, 'There is delete button.');
// Check that there is no accept button on item review form.
$this
->assertNoFieldById('edit-accept', NULL, 'There is no accept button.');
$this
->drupalGet('admin/tmgmt/jobs/' . $job
->id());
// Check that there is no delete link on job overview.
$this
->assertNoLink('Delete');
}