You are here

public function PositionedRectangleTest::testResize in Image Effects 8.3

Same name and namespace in other branches
  1. 8 tests/src/Unit/PositionedRectangleTest.php \Drupal\Tests\image_effects\Unit\PositionedRectangleTest::testResize()
  2. 8.2 tests/src/Unit/PositionedRectangleTest.php \Drupal\Tests\image_effects\Unit\PositionedRectangleTest::testResize()

@covers ::resize @covers ::setPoint @covers ::getPoint

File

tests/src/Unit/PositionedRectangleTest.php, line 22

Class

PositionedRectangleTest
Tests the Rectangle algebra class.

Namespace

Drupal\Tests\image_effects\Unit

Code

public function testResize() {
  $rect = new PositionedRectangle(200, 100);
  $rect
    ->setPoint('test_a', [
    20,
    10,
  ]);
  $this
    ->assertSame(200, $rect
    ->getWidth());
  $this
    ->assertSame(100, $rect
    ->getHeight());
  $this
    ->assertSame([
    0,
    0,
  ], $rect
    ->getPoint('c_a'));
  $this
    ->assertSame([
    199,
    0,
  ], $rect
    ->getPoint('c_b'));
  $this
    ->assertSame([
    199,
    99,
  ], $rect
    ->getPoint('c_c'));
  $this
    ->assertSame([
    0,
    99,
  ], $rect
    ->getPoint('c_d'));
  $this
    ->assertSame([
    0,
    0,
  ], $rect
    ->getPoint('o_a'));
  $this
    ->assertSame([
    199,
    99,
  ], $rect
    ->getPoint('o_c'));
  $this
    ->assertSame([
    20,
    10,
  ], $rect
    ->getPoint('test_a'));
  $rect
    ->resize(137, 54);
  $this
    ->assertSame(137, $rect
    ->getWidth());
  $this
    ->assertSame(54, $rect
    ->getHeight());
  $this
    ->assertSame([
    0,
    0,
  ], $rect
    ->getPoint('c_a'));
  $this
    ->assertSame([
    136,
    0,
  ], $rect
    ->getPoint('c_b'));
  $this
    ->assertSame([
    136,
    53,
  ], $rect
    ->getPoint('c_c'));
  $this
    ->assertSame([
    0,
    53,
  ], $rect
    ->getPoint('c_d'));
  $this
    ->assertSame([
    0,
    0,
  ], $rect
    ->getPoint('o_a'));
  $this
    ->assertSame([
    136,
    53,
  ], $rect
    ->getPoint('o_c'));
  $this
    ->assertSame([
    14,
    5,
  ], $rect
    ->getPoint('test_a'));
}