You are here

public function RefreshPageElementsHelperTest::testAjaxResponseNoStatusMessagesBlock in Commerce Ajax Add to Cart 8

Tests ajax response when status messages block is not placed.

@covers ::getResponse @covers ::updateStatusMessages

File

tests/src/Kernel/RefreshPageElementsHelperTest.php, line 199

Class

RefreshPageElementsHelperTest
Tests RefreshPageElementsHelper methods.

Namespace

Drupal\Tests\dc_ajax_add_cart\Kernel

Code

public function testAjaxResponseNoStatusMessagesBlock() {
  $refreshPageElements = $this->refreshPageElementsHelper
    ->updateStatusMessages();
  $this
    ->assertInstanceOfRefreshPageElementsHelper($refreshPageElements);
  $response = $refreshPageElements
    ->getResponse();
  $this
    ->assertAjaxResponse($response);

  // The returned response should not have the expected ajax commands.
  $ajax_commands = $response
    ->getCommands();
  $actual_ajax_command_names = array_map(function ($i) {
    return $i['command'];
  }, $ajax_commands);
  foreach ($this->expectedAjaxCommandNamesStatusMessagesUpdate as $ajax_command_name) {
    $this
      ->assertFalse(in_array($ajax_command_name, $actual_ajax_command_names), "{$ajax_command_name} is present");
  }
}