Common.php in Feeds Paragraphs 8
File
tests/src/Unit/Helpers/Common.php
View source
<?php
namespace Drupal\Tests\feeds_para_mapper\Unit\Helpers;
use Drupal\feeds\Feeds\Target\Text;
use Drupal\feeds_para_mapper\Utility\TargetInfo;
use Prophecy\Argument;
trait Common {
public function getTargetInfo() {
$targetInfo = new TargetInfo();
$targetInfo->type = $this
->getType();
$targetInfo->in_common = array();
$targetInfo->path = array();
$targetInfo->paragraphs = array();
$targetInfo->max_values = 1;
$targetInfo->has_settings = true;
$targetInfo->plugin = array(
"class" => $this
->getClass(),
"id" => $this
->getType(),
);
return $targetInfo;
}
function getClass() {
return $this->class;
}
function getType() {
return $this->type;
}
public function getInstanceMock() {
$defaultConfig = array(
'format' => 'default format',
);
$text = $this
->prophesize(Text::class);
$form = array();
$form['format'] = [
'#type' => 'select',
'#title' => 'Filter format',
'#options' => array(
'a',
'b',
'c',
),
];
$translation = $this
->getStringTranslationStub();
$text
->defaultConfiguration()
->willReturn($defaultConfig);
$text
->buildConfigurationForm(Argument::type('array'), Argument::any())
->willReturn($form);
$text
->submitConfigurationForm(Argument::any(), Argument::any())
->willReturn(null);
$text
->getSummary()
->willReturn($translation
->translate("test summary"));
$that = $this;
$text
->setTarget(Argument::any(), Argument::any(), Argument::any(), Argument::any())
->will(function ($args) use ($that) {
$that->entityHelper->values[$args[2]] = $args[3];
});
return $text;
}
}