You are here

public function FeedTypeTamperMetaTest::setUp in Feeds Tamper 8.2

Same name in this branch
  1. 8.2 tests/src/Unit/FeedTypeTamperMetaTest.php \Drupal\Tests\feeds_tamper\Unit\FeedTypeTamperMetaTest::setUp()
  2. 8.2 tests/src/Kernel/FeedTypeTamperMetaTest.php \Drupal\Tests\feeds_tamper\Kernel\FeedTypeTamperMetaTest::setUp()

Overrides FeedsKernelTestBase::setUp

File

tests/src/Kernel/FeedTypeTamperMetaTest.php, line 26

Class

FeedTypeTamperMetaTest
@coversDefaultClass \Drupal\feeds_tamper\FeedTypeTamperMeta @group feeds_tamper

Namespace

Drupal\Tests\feeds_tamper\Kernel

Code

public function setUp() {
  parent::setUp();
  $container = \Drupal::getContainer();

  // Mock the UUID generator and let it always return 'uuid3'.
  $uuid_generator = $this
    ->createMock(UuidInterface::class);
  $uuid_generator
    ->expects($this
    ->any())
    ->method('generate')
    ->will($this
    ->returnValue('uuid3'));

  // Get the tamper manager.
  $tamper_manager = $container
    ->get('plugin.manager.tamper');

  // Mock the feed type and let it always return two tampers.
  $feed_type = $this
    ->createMock(FeedTypeInterface::class);
  $feed_type
    ->expects($this
    ->any())
    ->method('getThirdPartySetting')
    ->with('feeds_tamper', 'tampers')
    ->will($this
    ->returnValue([
    'uuid1' => [
      'uuid' => 'uuid1',
      'plugin' => 'explode',
      'separator' => '|',
      'source' => 'alpha',
      'description' => 'Explode with pipe character',
    ],
    'uuid2' => [
      'uuid' => 'uuid2',
      'plugin' => 'convert_case',
      'operation' => 'strtoupper',
      'source' => 'beta',
      'description' => 'Convert all characters to uppercase',
    ],
  ]));
  $feed_type
    ->expects($this
    ->any())
    ->method('getMappingSources')
    ->will($this
    ->returnValue([
    'alpha' => [
      'label' => 'Alpha',
    ],
    'beta' => [
      'label' => 'Beta',
    ],
  ]));

  // Instantiate a feeds type tamper meta object.
  $this->feedTypeTamperMeta = new FeedTypeTamperMeta($uuid_generator, $tamper_manager, $feed_type);
}