public function FeedTypeTamperMetaTest::createFeedTypeTamperMeta in Feeds Tamper 8.2
Creates a new FeedTypeTamperMeta.
Parameters
array $mapping_sources: The array which will be returned by FeedType's mappingSources().
Return value
Drupal\feeds_tamper\FeedTypeTamperMeta The FeedTypeTamperMeta object used for testing.
2 calls to FeedTypeTamperMetaTest::createFeedTypeTamperMeta()
- FeedTypeTamperMetaTest::setUp in tests/
src/ Unit/ FeedTypeTamperMetaTest.php - FeedTypeTamperMetaTest::testSourceDefinitionWithBlankLabels in tests/
src/ Unit/ FeedTypeTamperMetaTest.php - @covers ::getSourceDefinition
File
- tests/
src/ Unit/ FeedTypeTamperMetaTest.php, line 163
Class
- FeedTypeTamperMetaTest
- @coversDefaultClass \Drupal\feeds_tamper\FeedTypeTamperMeta @group feeds_tamper
Namespace
Drupal\Tests\feeds_tamper\UnitCode
public function createFeedTypeTamperMeta(array $mapping_sources) {
// 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 = $this
->createMock(TamperManagerInterface::class);
$tamper_manager
->expects($this
->any())
->method('createInstance')
->will($this
->returnValue($this
->createMock(TamperInterface::class)));
// Mock the feed type and let it always return two tampers.
$this->feed_type = $this
->createMock(FeedTypeInterface::class);
$this->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',
],
]));
$this->feed_type
->expects($this
->any())
->method('getMappingSources')
->will($this
->returnValue($mapping_sources));
// Instantiate a feeds type tamper meta object.
return new FeedTypeTamperMeta($uuid_generator, $tamper_manager, $this->feed_type);
}