You are here

public function PhoneInternationalFieldTest::testTelephoneFormatter in International Phone 3.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/PhoneInternationalFieldTest.php \Drupal\Tests\phone_international\Functional\PhoneInternationalFieldTest::testTelephoneFormatter()
  2. 8 tests/src/Functional/PhoneInternationalFieldTest.php \Drupal\Tests\phone_international\Functional\PhoneInternationalFieldTest::testTelephoneFormatter()

Test the phone_international formatter.

@covers \Drupal\phone_international\Plugin\Field\FieldFormatter\PhoneInternationalDefaultFormatter::viewElements

@dataProvider providerPhoneNumbers

File

tests/src/Functional/PhoneInternationalFieldTest.php, line 114

Class

PhoneInternationalFieldTest
Simple test to ensure that main page loads with module enabled.

Namespace

Drupal\Tests\phone_international\Functional

Code

public function testTelephoneFormatter($input, $expected) {
  $entity = EntityTest::create();
  $entity->{$this->fieldname}->value = $input;
  $entity
    ->save();
  $id = $entity
    ->id();
  $entity = EntityTest::load($id);

  // Verify entity value field is correct.
  $entity = EntityTest::load($entity
    ->id());
  $this
    ->assertEquals($expected, $entity->{$this->fieldname}->value);

  // Verify when page is load.
  $this
    ->drupalGet($entity
    ->toUrl());
  $this
    ->assertSession()
    ->responseContains($expected);
}