You are here

public function RecipientGatewayEventTest::testGatewayRemoveAllSameId in SMS Framework 8

Same name and namespace in other branches
  1. 2.x tests/src/Unit/Event/RecipientGatewayEventTest.php \Drupal\Tests\sms\Unit\Event\RecipientGatewayEventTest::testGatewayRemoveAllSameId()
  2. 2.1.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 144

Class

RecipientGatewayEventTest
Unit Tests for SmsMessage.

Namespace

Drupal\Tests\sms\Unit\Event

Code

public function testGatewayRemoveAllSameId() {
  $event = $this
    ->createEvent($this
    ->randomPhoneNumbers()[0]);
  $gateway = $this
    ->getMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_1');
  $event
    ->addGateway($gateway, 200);
  $gateway = $this
    ->getMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_1');
  $event
    ->addGateway($gateway, 400);
  $gateway = $this
    ->getMock(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.');
}