You are here

public function Drupal8Test::testSetEntityProperty in Realistic Dummy Content 3.x

Test for setEntityProperty().

@cover ::setEntityProperty @dataProvider providerSetEntityProperty

Parameters

string $message: The test message.

mixed $entity: The mock entity.

mixed $property: The mock property.

mixed $value: The mock value.

mixed $expected: The expected resulting entity.

File

api/tests/src/Unit/Framework/Drupal8Test.php, line 32

Class

Drupal8Test
Tests for \Drupal\realistic_dummy_content_api\Framework\Drupal8.

Namespace

Drupal\Tests\realistic_dummy_content_api\Unit\Framework

Code

public function testSetEntityProperty(string $message, $entity, $property, $value, $expected) {
  $object = $this
    ->getMockBuilder(Drupal8::class)
    ->setMethods(NULL)
    ->disableOriginalConstructor()
    ->getMock();
  $output = $entity;
  $object
    ->setEntityProperty($output, $property, $value);
  if ($output != $expected) {
    print_r([
      'output' => $output,
      'expected' => $expected,
    ]);
  }
  $this
    ->assertTrue($output == $expected, $message);
}