You are here

public function PaymentReferenceTest::testGetPaymentDescription in Payment 8.2

@covers ::getPaymentDescription

@depends testGetEntityTypeId @depends testGetBundle @depends testGetFieldName

File

modules/payment_reference/tests/src/Unit/Plugin/Payment/Type/PaymentReferenceTest.php, line 155

Class

PaymentReferenceTest
@coversDefaultClass \Drupal\payment_reference\Plugin\Payment\Type\PaymentReference

Namespace

Drupal\Tests\payment_reference\Unit\Plugin\Payment\Type

Code

public function testGetPaymentDescription() {
  $entity_type_id = $this
    ->randomMachineName();
  $bundle = $this
    ->randomMachineName();
  $field_name = $this
    ->randomMachineName();
  $label = $this
    ->randomMachineName();
  $field_definition = $this
    ->createMock(FieldDefinitionInterface::class);
  $field_definition
    ->expects($this
    ->atLeastOnce())
    ->method('getLabel')
    ->willReturn($label);
  $definitions = array(
    $field_name => $field_definition,
  );
  $this->entityFieldManager
    ->expects($this
    ->atLeastOnce())
    ->method('getFieldDefinitions')
    ->with($entity_type_id, $bundle)
    ->willReturn($definitions);
  $this->sut
    ->setEntityTypeId($entity_type_id);
  $this->sut
    ->setBundle($bundle);
  $this->sut
    ->setFieldName($field_name);
  $this
    ->assertSame($label, $this->sut
    ->getPaymentDescription());
}