You are here

public function TestMapper::testBuildPath in Feeds Paragraphs 8

@covers ::buildPath

File

tests/src/Unit/TestMapper.php, line 189

Class

TestMapper
@group Feeds Paragraphs @coversDefaultClass \Drupal\feeds_para_mapper\Mapper

Namespace

Drupal\Tests\feeds_para_mapper\Unit

Code

public function testBuildPath() {
  $method = $this
    ->getMethod(Mapper::class, 'buildPath');
  $field = $this->fieldHelper
    ->getBundleFields('bundle_two')[0]
    ->reveal();
  $first_host = array(
    'bundle' => 'bundle_one',
    'host_field' => 'paragraph_field',
    'host_entity' => 'node',
    'order' => 0,
  );
  $path = $method
    ->invokeArgs($this->mapper, array(
    $field,
    $first_host,
  ));
  self::assertTrue(is_array($path) && count($path), "Field path exists");
  $bundles = $this->fieldHelper->bundles;
  $bundles = array_values($bundles);
  for ($i = 0; $i < count($bundles); $i++) {
    self::assertTrue($path[$i]['bundle'] === $bundles[$i], "bundle exists in the path");
  }
}