Updating Media dependent modules to versions compatible with core Media.
[yaffs-website] / web / modules / contrib / media_entity_twitter / tests / src / Kernel / ThumbnailTest.php
index 850b78a5d70d0ffb2ace0f3dfaf54deffc57596d..a39cda295b4bb436238d40243ab889b954949d90 100644 (file)
@@ -5,10 +5,9 @@ namespace Drupal\Tests\media_entity_twitter\Kernel;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
 use Drupal\KernelTests\KernelTestBase;
-use Drupal\media_entity\Entity\Media;
-use Drupal\media_entity\Entity\MediaBundle;
-use Drupal\media_entity\MediaInterface;
-use Drupal\media_entity_twitter\Plugin\MediaEntity\Type\Twitter;
+use Drupal\media\Entity\Media;
+use Drupal\media\Entity\MediaType;
+use Drupal\media_entity_twitter\Plugin\media\Source\Twitter;
 use Drupal\media_entity_twitter\TweetFetcherInterface;
 
 /**
@@ -21,21 +20,21 @@ class ThumbnailTest extends KernelTestBase {
   /**
    * The mocked tweet fetcher.
    *
-   * @var TweetFetcherInterface
+   * @var \Drupal\media_entity_twitter\TweetFetcherInterface
    */
   protected $tweetFetcher;
 
   /**
    * The plugin under test.
    *
-   * @var Twitter
+   * @var \Drupal\media_entity_twitter\Plugin\media\Source\Twitter
    */
   protected $plugin;
 
   /**
    * A tweet media entity.
    *
-   * @var MediaInterface
+   * @var \Drupal\media\MediaInterface
    */
   protected $entity;
 
@@ -46,7 +45,7 @@ class ThumbnailTest extends KernelTestBase {
     'field',
     'file',
     'image',
-    'media_entity',
+    'media',
     'media_entity_twitter',
     'system',
     'text',
@@ -65,10 +64,10 @@ class ThumbnailTest extends KernelTestBase {
     $this->tweetFetcher = $this->getMock(TweetFetcherInterface::class);
     $this->container->set('media_entity_twitter.tweet_fetcher', $this->tweetFetcher);
 
-    MediaBundle::create([
+    MediaType::create([
       'id' => 'tweet',
-      'type' => 'twitter',
-      'type_configuration' => [
+      'source' => 'twitter',
+      'source_configuration' => [
         'source_field' => 'tweet',
         'use_twitter_api' => TRUE,
         'consumer_key' => $this->randomString(),
@@ -97,9 +96,9 @@ class ThumbnailTest extends KernelTestBase {
 
     $this->plugin = Twitter::create(
       $this->container,
-      MediaBundle::load('tweet')->getTypeConfiguration(),
+      MediaType::load('tweet')->get('source_configuration'),
       'twitter',
-      []
+      MediaType::load('tweet')->getSource()->getPluginDefinition()
     );
 
     $dir = $this->container
@@ -128,7 +127,7 @@ class ThumbnailTest extends KernelTestBase {
 
     $uri = 'public://twitter-thumbnails/12345.ico';
     touch($uri);
-    $this->assertEquals($uri, $this->plugin->thumbnail($this->entity));
+    $this->assertEquals($uri, $this->plugin->getMetadata($this->entity, 'thumbnail_uri'));
   }
 
   /**
@@ -147,7 +146,7 @@ class ThumbnailTest extends KernelTestBase {
         ],
       ]);
 
-    $this->plugin->thumbnail($this->entity);
+    $this->plugin->getMetadata($this->entity, 'thumbnail_uri');
     $this->assertFileExists('public://twitter-thumbnails/12345.ico');
   }
 
@@ -156,8 +155,8 @@ class ThumbnailTest extends KernelTestBase {
    */
   public function testNoLocalImage() {
     $this->assertEquals(
-      $this->plugin->getDefaultThumbnail(),
-      $this->plugin->thumbnail($this->entity)
+      '/twitter.png',
+      $this->plugin->getMetadata($this->entity, 'thumbnail_uri')
     );
   }
 
@@ -169,7 +168,7 @@ class ThumbnailTest extends KernelTestBase {
     $configuration['generate_thumbnails'] = TRUE;
     $this->plugin->setConfiguration($configuration);
 
-    $uri = $this->plugin->thumbnail($this->entity);
+    $uri = $this->plugin->getMetadata($this->entity, 'thumbnail_uri');
     $this->assertFileExists($uri);
   }