You are here

public function ConfigEntityBaseUnitTest::testToArrayIdKey in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest::testToArrayIdKey()

@covers ::toArray

File

core/tests/Drupal/Tests/Core/Config/Entity/ConfigEntityBaseUnitTest.php, line 497
Contains \Drupal\Tests\Core\Config\Entity\ConfigEntityBaseUnitTest.

Class

ConfigEntityBaseUnitTest
@coversDefaultClass \Drupal\Core\Config\Entity\ConfigEntityBase @group Config

Namespace

Drupal\Tests\Core\Config\Entity

Code

public function testToArrayIdKey() {
  $entity = $this
    ->getMockForAbstractClass('\\Drupal\\Core\\Config\\Entity\\ConfigEntityBase', [
    [],
    $this->entityTypeId,
  ], '', TRUE, TRUE, TRUE, [
    'id',
    'get',
  ]);
  $entity
    ->expects($this
    ->atLeastOnce())
    ->method('id')
    ->willReturn($this->id);
  $entity
    ->expects($this
    ->once())
    ->method('get')
    ->with('dependencies')
    ->willReturn([]);
  $this->typedConfigManager
    ->expects($this
    ->never())
    ->method('getDefinition');
  $this->entityType
    ->expects($this
    ->any())
    ->method('getPropertiesToExport')
    ->willReturn([
    'id' => 'configId',
    'dependencies' => 'dependencies',
  ]);
  $this->entityType
    ->expects($this
    ->once())
    ->method('getKey')
    ->with('id')
    ->willReturn('id');
  $properties = $entity
    ->toArray();
  $this
    ->assertInternalType('array', $properties);
  $this
    ->assertEquals([
    'configId' => $entity
      ->id(),
    'dependencies' => [],
  ], $properties);
}