diff --git a/core/modules/system/tests/src/Functional/Batch/PageTest.php b/core/modules/system/tests/src/Functional/Batch/PageTest.php
index 94a1cbd..9692fb8 100644
--- a/core/modules/system/tests/src/Functional/Batch/PageTest.php
+++ b/core/modules/system/tests/src/Functional/Batch/PageTest.php
@@ -53,7 +53,7 @@ public function testBatchProgressPageTitle() {
$this->drupalGet('batch-test/test-title');
// The stack should contain the title shown on the progress page.
$this->assertEqual(batch_test_stack(), ['Batch Test'], 'The batch title is shown on the batch page.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $this->assertSession()->pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
}
/**
@@ -62,12 +62,13 @@ public function testBatchProgressPageTitle() {
public function testBatchProgressMessages() {
// Go to the initial step only.
$this->drupalGet('batch-test/test-title');
- $this->assertRaw('
Initializing.
', 'Initial progress message appears correctly.');
- $this->assertNoRaw(' ', 'Initial progress message is not double escaped.');
+ $assertSession = $this->assertSession();
+ $assertSession->responseContains('Initializing.
', 'Initial progress message appears correctly.');
+ $assertSession->responseNotContains(' ', 'Initial progress message is not double escaped.');
// Now also go to the next step.
$this->drupalGet('batch-test/test-title');
- $this->assertRaw('Completed 1 of 1.
', 'Progress message for second step appears correctly.');
+ $assertSession->responseContains('Completed 1 of 1.
', 'Progress message for second step appears correctly.');
}
}
diff --git a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php
index 2d7c7ae..409b2c8 100644
--- a/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php
+++ b/core/modules/system/tests/src/Functional/Batch/ProcessingTest.php
@@ -27,7 +27,8 @@ public function testBatchNoForm() {
$this->drupalGet('batch-test/no-form');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 2 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $this->assertSession()
+ ->pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
}
/**
@@ -38,7 +39,8 @@ public function testBatchRedirectFinishedCallback() {
$this->drupalGet('batch-test/finish-redirect');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 2 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.');
- $this->assertText('Test page text.', 'Custom redirection after batch execution displays the correct page.');
+ $this->assertSession()
+ ->pageTextContains('Test page text.', 'Custom redirection after batch execution displays the correct page.');
$this->assertUrl(Url::fromRoute('test_page_test.test_page'));
}
@@ -46,73 +48,84 @@ public function testBatchRedirectFinishedCallback() {
* Tests batches defined in a form submit handler.
*/
public function testBatchForm() {
+ $assertSession = $this->assertSession();
// Batch 0: no operation.
$edit = ['batch' => 'batch_0'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_0'), 'Batch with no operation performed successfully.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession
+ ->pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 1: several simple operations.
$edit = ['batch' => 'batch_1'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch with simple operations performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession
+ ->pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 2: one multistep operation.
$edit = ['batch' => 'batch_2'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch with multistep operation performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession
+ ->pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 3: simple + multistep combined.
$edit = ['batch' => 'batch_3'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_3'), 'Batch with simple and multistep operations performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_3'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession->
+ pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
// Batch 4: nested batch.
$edit = ['batch' => 'batch_4'];
$this->drupalPostForm('batch-test', $edit, 'Submit');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
$this->assertBatchMessages($this->_resultMessages('batch_4'), 'Nested batch performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_4'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession->
+ pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
}
/**
* Tests batches defined in a multistep form.
*/
public function testBatchFormMultistep() {
+ $assertSession = $this->assertSession();
$this->drupalGet('batch-test/multistep');
$this->assertNoEscaped('<', 'No escaped markup is present.');
- $this->assertText('step 1', 'Form is displayed in step 1.');
+ $assertSession->
+ pageTextContains('step 1', 'Form is displayed in step 1.');
// First step triggers batch 1.
$this->drupalPostForm(NULL, [], 'Submit');
$this->assertBatchMessages($this->_resultMessages('batch_1'), 'Batch for step 1 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_1'), 'Execution order was correct.');
- $this->assertText('step 2', 'Form is displayed in step 2.');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->
+ pageTextContains('step 2', 'Form is displayed in step 2.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
// Second step triggers batch 2.
$this->drupalPostForm(NULL, [], 'Submit');
$this->assertBatchMessages($this->_resultMessages('batch_2'), 'Batch for step 2 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_2'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
- $this->assertNoEscaped('<', 'No escaped markup is present.');
+ $assertSession->
+ pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
+ $assertSession->assertNoEscaped('<', 'No escaped markup is present.');
// Extra query arguments will trigger logic that will add them to the
// redirect URL. Make sure they are persisted.
$this->drupalGet('batch-test/multistep', ['query' => ['big_tree' => 'small_axe']]);
$this->drupalPostForm(NULL, [], 'Submit');
- $this->assertText('step 2', 'Form is displayed in step 2.');
+ $assertSession->
+ pageTextContains('step 2', 'Form is displayed in step 2.');
$this->assertTrue(strpos($this->getUrl(), 'batch-test/multistep?big_tree=small_axe'), 'Query argument was persisted and another extra argument was added.');
}
@@ -130,7 +143,8 @@ public function testBatchFormMultipleBatches() {
// The stack contains execution order of batch callbacks and submit
// handlers and logging of corresponding $form_state->getValues().
$this->assertEqual(batch_test_stack(), $this->_resultStack('chained', $value), 'Execution order was correct, and $form_state is correctly persisted.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $this->assertSession()->
+ pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
}
/**
@@ -148,7 +162,8 @@ public function testBatchFormProgrammatic() {
// The stack contains execution order of batch callbacks and submit
// handlers and logging of corresponding $form_state->getValues().
$this->assertEqual(batch_test_stack(), $this->_resultStack('chained', $value), 'Execution order was correct, and $form_state is correctly persisted.');
- $this->assertText('Got out of a programmatic batched form.', 'Page execution continues normally.');
+ $this->assertSession()->
+ pageTextContains('Got out of a programmatic batched form.', 'Page execution continues normally.');
}
/**
@@ -172,7 +187,8 @@ public function testBatchLargePercentage() {
$this->drupalGet('batch-test/large-percentage');
$this->assertBatchMessages($this->_resultMessages('batch_5'), 'Batch for step 2 performed successfully.');
$this->assertEqual(batch_test_stack(), $this->_resultStack('batch_5'), 'Execution order was correct.');
- $this->assertText('Redirection successful.', 'Redirection after batch execution is correct.');
+ $this->assertSession()->
+ pageTextContains('Redirection successful.', 'Redirection after batch execution is correct.');
}