You are here

public function RecipientGatewayEventTest::testSortFunction 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::testSortFunction()
  2. 2.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 27

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
    ->createMock(SmsGatewayInterface::class);
  $gateway
    ->expects($this
    ->any())
    ->method('id')
    ->willReturn('gateway_first');
  $event
    ->addGateway($gateway, 100);
  $gateway = $this
    ->createMock(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());
}