You are here

public function RecipientGatewayEventTest::testGatewayRemoveAllSameId in SMS Framework 2.1.x

Same name and namespace in other branches
  1. 8 tests/src/Unit/Event/RecipientGatewayEventTest.php \Drupal\Tests\sms\Unit\Event\RecipientGatewayEventTest::testGatewayRemoveAllSameId()
  2. 2.x tests/src/Unit/Event/RecipientGatewayEventTest.php \Drupal\Tests\sms\Unit\Event\RecipientGatewayEventTest::testGatewayRemoveAllSameId()

Tests removing gateways with same identifier.

@covers ::removeGateway

File

tests/src/Unit/Event/RecipientGatewayEventTest.php, line 146

Class

RecipientGatewayEventTest
Unit Tests for SmsMessage.

Namespace

Drupal\Tests\sms\Unit\Event

Code

public function testGatewayRemoveAllSameId() {
  $event = $this
    ->createEvent($this
    ->randomPhoneNumbers()[0]);
  $gateway = $this
    ->createMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_1');
  $event
    ->addGateway($gateway, 200);
  $gateway = $this
    ->createMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_1');
  $event
    ->addGateway($gateway, 400);
  $gateway = $this
    ->createMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_2');
  $event
    ->addGateway($gateway, 600);
  $this
    ->assertEquals(3, count($event
    ->getGateways()), 'There are three gateways.');
  $event
    ->removeGateway('gateway_1');
  $this
    ->assertEquals(1, count($event
    ->getGateways()), 'Two gateways were removed.');
}