public function FileTest::setUp in Feeds 8.3
Same name in this branch
- 8.3 tests/src/Functional/Feeds/Target/FileTest.php \Drupal\Tests\feeds\Functional\Feeds\Target\FileTest::setUp()
- 8.3 tests/src/Unit/Feeds/Target/FileTest.php \Drupal\Tests\feeds\Unit\Feeds\Target\FileTest::setUp()
Overrides FeedsUnitTestCase::setUp
File
- tests/
src/ Unit/ Feeds/ Target/ FileTest.php, line 66
Class
- FileTest
- @coversDefaultClass \Drupal\feeds\Feeds\Target\File @group feeds
Namespace
Drupal\Tests\feeds\Unit\Feeds\TargetCode
public function setUp() {
parent::setUp();
$this->entityTypeManager = $this
->prophesize(EntityTypeManagerInterface::class);
$this->client = $this
->prophesize(ClientInterface::class);
$this->token = $this
->prophesize(Token::class);
$this->entityFieldManager = $this
->prophesize(EntityFieldManagerInterface::class);
$this->entityFieldManager
->getFieldStorageDefinitions('file')
->willReturn([]);
$this->entityFinder = $this
->prophesize(EntityFinderInterface::class);
$this->fileSystem = $this
->prophesize(FileSystemInterface::class);
// Made-up entity type that we are referencing to.
$referenceable_entity_type = $this
->prophesize(EntityTypeInterface::class);
$referenceable_entity_type
->getKey('label')
->willReturn('file label');
$this->entityTypeManager
->getDefinition('file')
->willReturn($referenceable_entity_type)
->shouldBeCalled();
$method = $this
->getMethod('Drupal\\feeds\\Feeds\\Target\\File', 'prepareTarget')
->getClosure();
$field_definition_mock = $this
->getMockFieldDefinition([
'display_field' => 'false',
'display_default' => 'false',
'uri_scheme' => 'public',
'target_type' => 'file',
'file_directory' => '[date:custom:Y]-[date:custom:m]',
'file_extensions' => 'pdf doc docx txt jpg jpeg ppt xls png',
'max_filesize' => '',
'description_field' => 'true',
'handler' => 'default:file',
'handler_settings' => [],
]);
$configuration = [
'feed_type' => $this
->createMock('Drupal\\feeds\\FeedTypeInterface'),
'target_definition' => $method($field_definition_mock),
];
$this->targetPlugin = new File($configuration, 'file', [], $this->entityTypeManager
->reveal(), $this->client
->reveal(), $this->token
->reveal(), $this->entityFieldManager
->reveal(), $this->entityFinder
->reveal(), $this->fileSystem
->reveal());
}