protected function ThumbnailTest::setUp in Media entity Twitter 8.2
Same name and namespace in other branches
- 8 tests/src/Kernel/ThumbnailTest.php \Drupal\Tests\media_entity_twitter\Kernel\ThumbnailTest::setUp()
Overrides KernelTestBase::setUp
File
- tests/
src/ Kernel/ ThumbnailTest.php, line 59
Class
- ThumbnailTest
- Tests SVG thumbnail generation from Twitter API responses.
Namespace
Drupal\Tests\media_entity_twitter\KernelCode
protected function setUp() {
parent::setUp();
$this
->installEntitySchema('file');
$this
->installEntitySchema('media');
$this
->installConfig([
'media_entity_twitter',
'system',
]);
$this->tweetFetcher = $this
->createMock(TweetFetcherInterface::class);
$this->container
->set('media_entity_twitter.tweet_fetcher', $this->tweetFetcher);
MediaType::create([
'id' => 'tweet',
'source' => 'twitter',
'source_configuration' => [
'source_field' => 'tweet',
'use_twitter_api' => TRUE,
'consumer_key' => $this
->randomString(),
'consumer_secret' => $this
->randomString(),
'oauth_access_token' => $this
->randomString(),
'oauth_access_token_secret' => $this
->randomString(),
],
])
->save();
FieldStorageConfig::create([
'field_name' => 'tweet',
'entity_type' => 'media',
'type' => 'string_long',
])
->save();
FieldConfig::create([
'field_name' => 'tweet',
'entity_type' => 'media',
'bundle' => 'tweet',
])
->save();
$this->entity = Media::create([
'bundle' => 'tweet',
'tweet' => 'https://twitter.com/foobar/status/12345',
]);
$this->plugin = Twitter::create($this->container, MediaType::load('tweet')
->get('source_configuration'), 'twitter', MediaType::load('tweet')
->getSource()
->getPluginDefinition());
$dir = $this->container
->get('config.factory')
->get('media_entity_twitter.settings')
->get('local_images');
\Drupal::service('file_system')
->prepareDirectory($dir, FileSystemInterface::CREATE_DIRECTORY | FileSystemInterface::MODIFY_PERMISSIONS);
}