You are here

public function RecipientGatewayEventTest::testGatewayRemove 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::testGatewayRemove()
  2. 2.x tests/src/Unit/Event/RecipientGatewayEventTest.php \Drupal\Tests\sms\Unit\Event\RecipientGatewayEventTest::testGatewayRemove()

Tests removing gateway with both ID and priority.

@covers ::removeGateway

File

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

Class

RecipientGatewayEventTest
Unit Tests for SmsMessage.

Namespace

Drupal\Tests\sms\Unit\Event

Code

public function testGatewayRemove() {
  $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', 400);
  $this
    ->assertEquals(2, count($event
    ->getGateways()), 'One gateways was removed.');
}