summaryrefslogtreecommitdiffstats
path: root/core/modules/block/tests
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/block/tests')
-rw-r--r--core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php5
-rw-r--r--core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php2
-rw-r--r--core/modules/block/tests/modules/block_test/src/Form/TestForm.php2
-rw-r--r--core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php5
-rw-r--r--core/modules/block/tests/src/Kernel/BlockRebuildTest.php9
5 files changed, 15 insertions, 8 deletions
diff --git a/core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php b/core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php
index e7aac65..246bcea 100644
--- a/core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php
+++ b/core/modules/block/tests/modules/block_test/src/Controller/TestMultipleFormController.php
@@ -17,7 +17,8 @@ class TestMultipleFormController extends ControllerBase {
'form2' => $this->formBuilder()->buildForm('\Drupal\block_test\Form\FavoriteAnimalTestForm', $form_state),
];
- // Output all attached placeholders trough drupal_set_message(), so we can
+ // Output all attached placeholders trough
+ // \Drupal\Core\Messenger\MessengerInterface::addMessage(), so we can
// see if there's only one in the tests.
$post_render_callable = function ($elements) {
$matches = [];
@@ -26,7 +27,7 @@ class TestMultipleFormController extends ControllerBase {
$action_values = $matches[2];
foreach ($action_values as $action_value) {
- drupal_set_message('Form action: ' . $action_value);
+ $this->messenger()->addStatus('Form action: ' . $action_value);
}
return $elements;
};
diff --git a/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php b/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php
index 3ad55ed..a86db68 100644
--- a/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php
+++ b/core/modules/block/tests/modules/block_test/src/Form/FavoriteAnimalTestForm.php
@@ -40,7 +40,7 @@ class FavoriteAnimalTestForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message($this->t('Your favorite animal is: @favorite_animal', ['@favorite_animal' => $form['favorite_animal']['#value']]));
+ $this->messenger()->addStatus($this->t('Your favorite animal is: @favorite_animal', ['@favorite_animal' => $form['favorite_animal']['#value']]));
}
}
diff --git a/core/modules/block/tests/modules/block_test/src/Form/TestForm.php b/core/modules/block/tests/modules/block_test/src/Form/TestForm.php
index 7fa645d..7619d84 100644
--- a/core/modules/block/tests/modules/block_test/src/Form/TestForm.php
+++ b/core/modules/block/tests/modules/block_test/src/Form/TestForm.php
@@ -49,7 +49,7 @@ class TestForm extends FormBase {
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state) {
- drupal_set_message($this->t('Your email address is @email', ['@email' => $form['email']['#value']]));
+ $this->messenger()->addStatus($this->t('Your email address is @email', ['@email' => $form['email']['#value']]));
}
}
diff --git a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
index 7db350d..70afd54 100644
--- a/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
+++ b/core/modules/block/tests/modules/block_test/src/Plugin/Block/TestContextAwareBlock.php
@@ -3,6 +3,7 @@
namespace Drupal\block_test\Plugin\Block;
use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Messenger\MessengerTrait;
use Drupal\Core\Session\AccountInterface;
use Drupal\user\UserInterface;
@@ -19,6 +20,8 @@ use Drupal\user\UserInterface;
*/
class TestContextAwareBlock extends BlockBase {
+ use MessengerTrait;
+
/**
* {@inheritdoc}
*/
@@ -37,7 +40,7 @@ class TestContextAwareBlock extends BlockBase {
*/
protected function blockAccess(AccountInterface $account) {
if ($this->getContextValue('user') instanceof UserInterface) {
- drupal_set_message('User context found.');
+ $this->messenger()->addStatus('User context found.');
}
return parent::blockAccess($account);
diff --git a/core/modules/block/tests/src/Kernel/BlockRebuildTest.php b/core/modules/block/tests/src/Kernel/BlockRebuildTest.php
index 33de12c..2443c21 100644
--- a/core/modules/block/tests/src/Kernel/BlockRebuildTest.php
+++ b/core/modules/block/tests/src/Kernel/BlockRebuildTest.php
@@ -47,7 +47,8 @@ class BlockRebuildTest extends KernelTestBase {
*/
public function testRebuildNoBlocks() {
block_rebuild();
- $messages = drupal_get_messages();
+ $messages = \Drupal::messenger()->all();
+ \Drupal::messenger()->deleteAll();
$this->assertEquals([], $messages);
}
@@ -58,7 +59,8 @@ class BlockRebuildTest extends KernelTestBase {
$this->placeBlock('system_powered_by_block', ['region' => 'content']);
block_rebuild();
- $messages = drupal_get_messages();
+ $messages = \Drupal::messenger()->all();
+ \Drupal::messenger()->deleteAll();
$this->assertEquals([], $messages);
}
@@ -89,7 +91,8 @@ class BlockRebuildTest extends KernelTestBase {
$block1 = Block::load($block1->id());
$block2 = Block::load($block2->id());
- $messages = drupal_get_messages();
+ $messages = \Drupal::messenger()->all();
+ \Drupal::messenger()->deleteAll();
$expected = ['warning' => [new TranslatableMarkup('The block %info was assigned to the invalid region %region and has been disabled.', ['%info' => $block1->id(), '%region' => 'INVALID'])]];
$this->assertEquals($expected, $messages);