You are here

ImageResourceUrlTest.php in GraphQL 8.4

File

tests/src/Kernel/DataProducer/Images/ImageResourceUrlTest.php
View source
<?php

namespace Drupal\Tests\graphql\Kernel\DataProducer\Images;

use Drupal\Tests\graphql\Kernel\GraphQLTestBase;

/**
 * Test class for the ImageResourceUrl data producer.
 *
 * @group graphql
 */
class ImageResourceUrlTest extends GraphQLTestBase {

  /**
   * @covers \Drupal\graphql\Plugin\GraphQL\DataProducer\Images\ImageResourceUrl::resolve
   *
   * @dataProvider testImageResourceUrlProvider
   */
  public function testImageResourceUrl(array $input, string $expected) : void {
    $result = $this
      ->executeDataProducer('image_style_url', [
      'derivative' => $input,
    ]);
    $this
      ->assertEquals($expected, $result);
  }

  /**
   * Provider for testImageResourceUrl().
   */
  public function testImageResourceUrlProvider() : array {
    return [
      [
        [
          'url' => 'http://localhost/test_image.jpg',
        ],
        'http://localhost/test_image.jpg',
      ],
      [
        [],
        '',
      ],
    ];
  }

}

Classes

Namesort descending Description
ImageResourceUrlTest Test class for the ImageResourceUrl data producer.