Skip to content
Snippets Groups Projects
Commit 35c02e8d authored by Benjamin Melançon's avatar Benjamin Melançon
Browse files

Issue #3299516 by Project Update Bot, beunerd, Jaydev Bhatt, szato, mlncn:...

Issue #3299516 by Project Update Bot, beunerd, Jaydev Bhatt, szato, mlncn: Drupal 10 compatibility fixes
parent 2c721806
No related branches found
No related tags found
No related merge requests found
......@@ -52,8 +52,9 @@ class ModerationFormTest extends ModerationStateTestBase {
* @see \Drupal\Tests\content_moderation\Functional\ModerationStateBlockTest::testCustomBlockModeration
*/
public function testModerationForm() {
$this->drupalGet('node/add/moderated_content');
// Create new moderated content in draft.
$this->drupalPostForm('node/add/moderated_content', [
$this->submitForm([
'title[0][value]' => 'Some moderated content',
'body[0][value]' => 'First version of the content.',
], $this->t('Save and Create New Draft'));
......@@ -68,73 +69,77 @@ class ModerationFormTest extends ModerationStateTestBase {
// The canonical view should have a moderation form, because it is not the
// live revision.
$this->drupalGet($canonical_path);
$this->assertResponse(200);
$this->assertField('edit-new-state', 'The node view page has a moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldExists('edit-new-state', 'The node view page has a moderation form.');
// The latest version page should not show, because there is no pending
// revision.
$this->drupalGet($latest_version_path);
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet($edit_path);
// Update the draft.
$this->drupalPostForm($edit_path, [
$this->submitForm([
'body[0][value]' => 'Second version of the content.',
], $this->t('Save and Create New Draft'));
// The canonical view should have a moderation form, because it is not the
// live revision.
$this->drupalGet($canonical_path);
$this->assertResponse(200);
$this->assertField('edit-new-state', 'The node view page has a moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldExists('edit-new-state', 'The node view page has a moderation form.');
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet($latest_version_path);
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet($edit_path);
// Publish the draft.
$this->drupalPostForm($edit_path, [
$this->submitForm([
'body[0][value]' => 'Third version of the content.',
], $this->t('Save and Publish'));
// The published view should not have a moderation form, because it is the
// live revision.
$this->drupalGet($canonical_path);
$this->assertResponse(200);
$this->assertNoField('edit-new-state', 'The node view page has no moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldNotExists('edit-new-state', 'The node view page has no moderation form.');
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet($latest_version_path);
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet($edit_path);
// Make a pending revision.
$this->drupalPostForm($edit_path, [
$this->submitForm([
'body[0][value]' => 'Fourth version of the content.',
], $this->t('Save and Create New Draft'));
// The published view should not have a moderation form, because it is the
// live revision.
$this->drupalGet($canonical_path);
$this->assertResponse(200);
$this->assertNoField('edit-new-state', 'The node view page has no moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldNotExists('edit-new-state', 'The node view page has no moderation form.');
// The latest version page should show the moderation form and have "Draft"
// status, because the pending revision is in "Draft".
$this->drupalGet($latest_version_path);
$this->assertResponse(200);
$this->assertField('edit-new-state', 'The latest-version page has a moderation form.');
$this->assertText('Draft', 'Correct status found on the latest-version page.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->fieldExists('edit-new-state', 'The latest-version page has a moderation form.');
$this->assertSession()->pageTextContains('Draft');
$this->drupalGet($latest_version_path);
// Submit the moderation form to change status to published.
$this->drupalPostForm($latest_version_path, [
$this->submitForm([
'new_state' => 'published',
], $this->t('Apply'));
// The latest version page should not show, because there is no
// pending revision.
$this->drupalGet($latest_version_path);
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
}
/**
......@@ -147,61 +152,66 @@ class ModerationFormTest extends ModerationStateTestBase {
$workflow->save();
drupal_flush_all_caches();
$this->drupalGet('entity_test_mulrevpub/add');
// Create new moderated content in draft.
$this->drupalPostForm('entity_test_mulrevpub/add', [], $this->t('Save and Create New Draft'));
$this->submitForm([], $this->t('Save and Create New Draft'));
// The latest version page should not show, because there is no pending
// revision.
$this->drupalGet('/entity_test_mulrevpub/manage/1/latest');
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
// Update the draft.
$this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', [], $this->t('Save and Create New Draft'));
$this->submitForm([], $this->t('Save and Create New Draft'));
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet('/entity_test_mulrevpub/manage/1/latest');
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
// Publish the draft.
$this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', [], $this->t('Save and Publish'));
$this->submitForm([], $this->t('Save and Publish'));
// The published view should not have a moderation form, because it is the
// default revision.
$this->drupalGet('entity_test_mulrevpub/manage/1');
$this->assertResponse(200);
$this->assertNoText('Status', 'The node view page has no moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextNotContains('Status');
// The latest version page should not show, because there is still no
// pending revision.
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
$this->drupalGet('entity_test_mulrevpub/manage/1/edit');
// Make a pending revision.
$this->drupalPostForm('entity_test_mulrevpub/manage/1/edit', [], $this->t('Save and Create New Draft'));
$this->submitForm([], $this->t('Save and Create New Draft'));
// The published view should not have a moderation form, because it is the
// default revision.
$this->drupalGet('entity_test_mulrevpub/manage/1');
$this->assertResponse(200);
$this->assertNoText('Status', 'The node view page has no moderation form.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextNotContains('Status');
// The latest version page should show the moderation form and have "Draft"
// status, because the pending revision is in "Draft".
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertResponse(200);
$this->assertText('Draft', 'Correct status found on the latest-version page.');
$this->assertSession()->statusCodeEquals(200);
$this->assertSession()->pageTextContains('Draft');
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
// Submit the moderation form to change status to published.
$this->drupalPostForm('entity_test_mulrevpub/manage/1/latest', [
$this->submitForm([
'new_state' => 'published',
], $this->t('Apply'));
// The latest version page should not show, because there is no
// pending revision.
$this->drupalGet('entity_test_mulrevpub/manage/1/latest');
$this->assertResponse(403);
$this->assertSession()->statusCodeEquals(403);
}
/**
......@@ -214,7 +224,8 @@ class ModerationFormTest extends ModerationStateTestBase {
$edit = [
'predefined_langcode' => 'fr',
];
$this->drupalPostForm('admin/config/regional/language/add', $edit, $this->t('Add language'));
$this->drupalGet('admin/config/regional/language/add');
$this->submitForm($edit, $this->t('Add language'));
// Enable content translation on articles.
$this->drupalGet('admin/config/regional/content-language');
......@@ -223,14 +234,15 @@ class ModerationFormTest extends ModerationStateTestBase {
'settings[node][moderated_content][translatable]' => TRUE,
'settings[node][moderated_content][settings][language][language_alterable]' => TRUE,
];
$this->drupalPostForm(NULL, $edit, $this->t('Save configuration'));
$this->submitForm($edit, $this->t('Save configuration'));
// Adding languages requires a container rebuild in the test running
// environment so that multilingual services are used.
$this->rebuildContainer();
$this->drupalGet('node/add/moderated_content');
// Create new moderated content in draft (revision 1).
$this->drupalPostForm('node/add/moderated_content', [
$this->submitForm([
'title[0][value]' => 'Some moderated content',
'body[0][value]' => 'First version of the content.',
], $this->t('Save and Create New Draft'));
......@@ -252,7 +264,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Second version of the content.',
], $this->t('Save and Publish (this translation)'));
......@@ -265,7 +277,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Third version of the content.',
], $this->t('Save and Create New Draft (this translation)'));
......@@ -294,7 +306,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Fifth version of the content.',
], $this->t('Save and Publish (this translation)'));
......@@ -306,7 +318,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Sixth version of the content.',
], $this->t('Save and Publish (this translation)'));
......@@ -324,7 +336,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Seventh version of the content.',
], $this->t('Save and Create New Draft (this translation)'));
......@@ -346,7 +358,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Eighth version of the content.',
], $this->t('Save and Publish (this translation)'));
......@@ -364,9 +376,10 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalGet('node/add/moderated_content');
// Create new moderated content. (revision 1).
$this->drupalPostForm('node/add/moderated_content', [
$this->submitForm([
'title[0][value]' => 'Second moderated content',
'body[0][value]' => 'First version of the content.',
], $this->t('Save and Publish'));
......@@ -381,7 +394,7 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [
$this->submitForm([
'body[0][value]' => 'Second version of the content.',
], $this->t('Save and Create New Draft (this translation)'));
......@@ -391,9 +404,10 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertFalse($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->assertSession()->pageTextContains('Unable to save this Moderated content.');
$this->drupalGet('node/add/moderated_content');
// Create new moderated content (revision 1).
$this->drupalPostForm('node/add/moderated_content', [
$this->submitForm([
'title[0][value]' => 'Third moderated content',
], $this->t('Save and Publish'));
......@@ -407,14 +421,14 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [], $this->t('Save and Create New Draft (this translation)'));
$this->submitForm([], $this->t('Save and Create New Draft (this translation)'));
// Add another draft for the translation (revision 3).
$this->drupalGet($edit_path, ['language' => $french]);
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [], $this->t('Save and Create New Draft (this translation)'));
$this->submitForm([], $this->t('Save and Create New Draft (this translation)'));
// Editing the original translation should not be possible.
$this->drupalGet($edit_path);
......@@ -428,14 +442,14 @@ class ModerationFormTest extends ModerationStateTestBase {
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertFalse($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [], $this->t('Save and Publish (this translation)'));
$this->submitForm([], $this->t('Save and Publish (this translation)'));
// Now the french translation is published, an english draft can be added.
$this->drupalGet($edit_path);
$this->assertTrue($this->xpath('//input[@value="Save and Create New Draft (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Publish (this translation)"]'));
$this->assertTrue($this->xpath('//input[@value="Save and Archive (this translation)"]'));
$this->drupalPostForm(NULL, [], $this->t('Save and Create New Draft (this translation)'));
$this->submitForm([], $this->t('Save and Create New Draft (this translation)'));
}
}
......@@ -71,7 +71,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// Save the node and assert it's published after clicking
// 'Save and publish'.
$edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, $this->t('Save and publish'));
$this->drupalGet('node/add/article');
$this->submitForm($edit, $this->t('Save and publish'));
// Get the node.
$node_1 = $node_storage->load(1);
......@@ -83,14 +84,15 @@ class NodeFormButtonsTest extends NodeTestBase {
// Save the node and verify it's still published after clicking
// 'Save and keep published'.
$this->drupalPostForm(NULL, $edit, $this->t('Save and keep published'));
$this->submitForm($edit, $this->t('Save and keep published'));
$node_storage->resetCache([1]);
$node_1 = $node_storage->load(1);
$this->assertTrue($node_1->isPublished(), 'Node is published');
$this->drupalGet('node/' . $node_1->id() . '/edit');
// Save the node and verify it's unpublished after clicking
// 'Save and unpublish'.
$this->drupalPostForm('node/' . $node_1->id() . '/edit', $edit, $this->t('Save and unpublish'));
$this->submitForm($edit, $this->t('Save and unpublish'));
$node_storage->resetCache([1]);
$node_1 = $node_storage->load(1);
$this->assertFalse($node_1->isPublished(), 'Node is unpublished');
......@@ -109,7 +111,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// Create the node.
$edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, $this->t('Save'));
$this->drupalGet('node/add/article');
$this->submitForm($edit, $this->t('Save'));
$node_2 = $node_storage->load(2);
$this->assertTrue($node_2->isPublished(), 'Node is published');
......@@ -117,7 +120,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// was created by the normal user.
$this->drupalLogout();
$this->drupalLogin($this->adminUser);
$this->drupalPostForm('node/' . $node_2->id() . '/edit', [], $this->t('Save and unpublish'));
$this->drupalGet('node/' . $node_2->id() . '/edit');
$this->submitForm([], $this->t('Save and unpublish'));
$node_storage->resetCache([2]);
$node_2 = $node_storage->load(2);
$this->assertFalse($node_2->isPublished(), 'Node is unpublished');
......@@ -126,7 +130,8 @@ class NodeFormButtonsTest extends NodeTestBase {
// it's still unpublished.
$this->drupalLogout();
$this->drupalLogin($this->webUser);
$this->drupalPostForm('node/' . $node_2->id() . '/edit', [], $this->t('Save'));
$this->drupalGet('node/' . $node_2->id() . '/edit');
$this->submitForm([], $this->t('Save'));
$node_storage->resetCache([2]);
$node_2 = $node_storage->load(2);
$this->assertFalse($node_2->isPublished(), 'Node is still unpublished');
......@@ -149,7 +154,8 @@ class NodeFormButtonsTest extends NodeTestBase {
$this->drupalLogout();
$this->drupalLogin($this->webUser);
$edit = ['title[0][value]' => $this->randomString()];
$this->drupalPostForm('node/add/article', $edit, $this->t('Save'));
$this->drupalGet('node/add/article');
$this->submitForm($edit, $this->t('Save'));
$node_3 = $node_storage->load(3);
$this->assertFalse($node_3->isPublished(), 'Node is unpublished');
}
......
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