You are here

protected function EntityTypeBundleInfoTest::createNewTestSubjectWithEntityType in Entity Construction Kit (ECK) 8

Creates a new test subject with an entity type.

Parameters

\Drupal\Core\Entity\EntityTypeInterface $entityTypeMock: The entity type mock.

\Drupal\Core\Entity\EntityStorageInterface $entityStorageMock: The entity storage mock.

Return value

\Drupal\eck\EckEntityTypeBundleInfo The test subject.

4 calls to EntityTypeBundleInfoTest::createNewTestSubjectWithEntityType()
EntityTypeBundleInfoTest::createNewTestSubjectWithEntityTypeAndBundles in tests/src/Unit/EntityTypeBundleInfoTest.php
Creates a new test subject with entity type and bundles.
EntityTypeBundleInfoTest::returnsFalseWhenEntityTypeHasNoBundles in tests/src/Unit/EntityTypeBundleInfoTest.php
Tests that entityTypeHasBundles returns false if it has no bundles.
EntityTypeBundleInfoTest::returnsNoMachineNamesIfEntityTypeHasNoBundles in tests/src/Unit/EntityTypeBundleInfoTest.php
Tests that no machine names are returned if there are no bundles.
EntityTypeBundleInfoTest::returnsZeroIfEntityTypeHasNoBundles in tests/src/Unit/EntityTypeBundleInfoTest.php
Tests that zero is returned if the entity type has no bundles.

File

tests/src/Unit/EntityTypeBundleInfoTest.php, line 210

Class

EntityTypeBundleInfoTest
Tests the form element implementation.

Namespace

Drupal\Tests\eck\Unit

Code

protected function createNewTestSubjectWithEntityType(EntityTypeInterface $entityTypeMock = NULL, EntityStorageInterface $entityStorageMock = NULL) {
  if (NULL === $entityTypeMock) {
    $entityTypeMock = $this
      ->getMockForAbstractClass(EntityTypeInterface::class);
    $entityTypeMock
      ->method('getBundleEntityType')
      ->willReturn('eck_entity_bundle');
  }
  if (NULL === $entityStorageMock) {
    $entityStorageMock = $this
      ->getMockForAbstractClass(EntityStorageInterface::class);
    $entityStorageMock
      ->method('loadMultiple')
      ->willReturn([]);
  }
  $this->entityTypeManagerMock = $this
    ->getMockForAbstractClass(EntityTypeManagerInterface::class);
  $this->entityTypeManagerMock
    ->method('getDefinitions')
    ->willReturn([
    'existing_entity_type' => $entityTypeMock,
  ]);
  $this->entityTypeManagerMock
    ->method('getStorage')
    ->willReturn($entityStorageMock);
  return $this
    ->createNewTestSubject();
}