You are here

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

Tests gateway sort.

@covers ::getGatewaysSorted

File

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

Class

RecipientGatewayEventTest
Unit Tests for SmsMessage.

Namespace

Drupal\Tests\sms\Unit\Event

Code

public function testSortFunction() {
  $number = $this
    ->randomPhoneNumbers()[0];
  $event = $this
    ->createEvent($number);
  $gateway = $this
    ->getMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_first');
  $event
    ->addGateway($gateway, 100);
  $gateway = $this
    ->getMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_second');
  $event
    ->addGateway($gateway, 200);
  $sorted = $event
    ->getGatewaysSorted();
  $this
    ->assertEquals(2, count($sorted));
  $this
    ->assertEquals('gateway_second', $sorted[0]
    ->id());
  $this
    ->assertEquals('gateway_first', $sorted[1]
    ->id());
}