You are here

public function ResourceTest::testSetDimensions in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/media/tests/src/Unit/ResourceTest.php \Drupal\Tests\media\Unit\ResourceTest::testSetDimensions()
  2. 9 core/modules/media/tests/src/Unit/ResourceTest.php \Drupal\Tests\media\Unit\ResourceTest::testSetDimensions()

@covers ::setDimensions @dataProvider setDimensionsTestCases

File

core/modules/media/tests/src/Unit/ResourceTest.php, line 78

Class

ResourceTest
@coversDefaultClass \Drupal\media\OEmbed\Resource @group media

Namespace

Drupal\Tests\media\Unit

Code

public function testSetDimensions($factory, $width, $height, $exception = NULL, $expected_width = NULL, $expected_height = NULL) {
  if ($exception) {
    $this
      ->expectException(\InvalidArgumentException::class);
    $this
      ->expectExceptionMessage($exception);
  }
  $resource = Resource::$factory('foo', $width, $height);
  $this
    ->assertSame($expected_width ?: $width, $resource
    ->getWidth());
  $this
    ->assertSame($expected_height ?: $height, $resource
    ->getHeight());
}