You are here

public function TestMapper::testUpdateInfo in Feeds Paragraphs 8

@covers ::updateInfo

File

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

Class

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

Namespace

Drupal\Tests\feeds_para_mapper\Unit

Code

public function testUpdateInfo() {

  // Test against a field with TargetInfo attached:
  $field = $this->fieldHelper
    ->getBundleFields('bundle_two')[0]
    ->reveal();
  $this->mapper
    ->updateInfo($field, 'path', array(
    'test' => 'test value',
  ));
  $info = $field
    ->get('target_info');
  $message = "TargetInfo property is updated";
  self::assertTrue(count($info->path) === 1 && $info->path['test'] === 'test value', $message);

  // Test against a field with no TargetInfo attached:
  $field
    ->set('target_info', null);
  $this->mapper
    ->updateInfo($field, 'path', array(
    'test' => 'test value 2',
  ));
  $info = $field
    ->get('target_info');
  $message = "TargetInfo property is updated";
  self::assertTrue(count($info->path) === 1 && $info->path['test'] === 'test value 2', $message);

  // Test with non-existing property:
  $res = $this->mapper
    ->updateInfo($field, 'test', 'test');
  $message = "should return false with non-existing property";
  self::assertFalse($res, $message);
}