diff --git a/core/tests/Drupal/Tests/Core/Image/ImageTest.php b/core/tests/Drupal/Tests/Core/Image/ImageTest.php index 67ca501..900d8da 100644 --- a/core/tests/Drupal/Tests/Core/Image/ImageTest.php +++ b/core/tests/Drupal/Tests/Core/Image/ImageTest.php @@ -222,8 +222,8 @@ public function testScaleWidth() { ->method('process') ->with($this->equalTo('resize')) ->will($this->returnArgument(2)); - $height = $this->image->scale(44); - $this->assertEquals($height, 50); + $result = $this->image->scale(44); + $this->assertEquals($result['height'], 50); } /** @@ -233,10 +233,10 @@ public function testScaleHeight() { $this->toolkit->expects($this->once()) ->method('process') ->with($this->equalTo('resize')) - ->will($this->returnArgument(1)); + ->will($this->returnArgument(2)); - $width = $this->image->scale(NULL, 50); - $this->assertEquals($width, 44); + $result = $this->image->scale(NULL, 50); + $this->assertEquals($result['width'], 44); } /** @@ -247,60 +247,57 @@ public function testScaleSame() { $this->toolkit->expects($this->never()) ->method('process') ->with($this->equalTo('resize')) - ->will($this->returnArgument(1)); + ->will($this->returnArgument(2)); - $width = $this->image->scale(88, 100); - $this->assertEquals($width, 88); + $result = $this->image->scale(88, 100); + $this->assertEquals($result['width'], 88); } /** * Tests \Drupal\Core\Image\Image::scaleAndCrop(). */ public function testScaleAndCropWidth() { - $this->toolkit->expects($this->once()) + $this->toolkit->expects($this->at(0)) ->method('process') ->with($this->equalTo('resize')) ->will($this->returnValue(TRUE)); - $this->toolkit->expects($this->once()) + $this->toolkit->expects($this->at(1)) ->method('process') ->with($this->equalTo('crop')) - ->will($this->returnArgument(1)); + ->will($this->returnArgument(2)); - $x = $this->image->scaleAndCrop(34, 50); - $this->assertEquals($x, 5); + $result = $this->image->scaleAndCrop(34, 50); + $this->assertEquals($result['x'], 5); } /** * Tests \Drupal\Core\Image\Image::scaleAndCrop(). */ public function testScaleAndCropHeight() { - $this->toolkit->expects($this->once()) + $this->toolkit->expects($this->at(0)) ->method('process') ->with($this->equalTo('resize')) ->will($this->returnValue(TRUE)); - $this->toolkit->expects($this->once()) + $this->toolkit->expects($this->at(1)) ->method('process') ->with($this->equalTo('crop')) ->will($this->returnArgument(2)); - $y = $this->image->scaleAndCrop(44, 40); - $this->assertEquals($y, 5); + $result = $this->image->scaleAndCrop(44, 40); + $this->assertEquals($result['y'], 5); } /** * Tests \Drupal\Core\Image\Image::scaleAndCrop(). */ public function testScaleAndCropFails() { - $this->toolkit->expects($this->once()) + $this->toolkit->expects($this->exactly(1)) ->method('process') ->with($this->equalTo('resize')) ->will($this->returnValue(FALSE)); - $this->toolkit->expects($this->never()) - ->method('process') - ->with($this->equalTo('crop')); $this->image->scaleAndCrop(44, 40); } @@ -311,10 +308,10 @@ public function testCropWidth() { $this->toolkit->expects($this->once()) ->method('process') ->with($this->equalTo('crop')) - ->will($this->returnArgument(4)); + ->will($this->returnArgument(2)); // Cropping with width only should preserve the aspect ratio. - $height = $this->image->crop(0, 0, 44, NULL); - $this->assertEquals($height, 50); + $result = $this->image->crop(0, 0, 44, NULL); + $this->assertEquals($result['height'], 50); } /** @@ -324,10 +321,10 @@ public function testCropHeight() { $this->toolkit->expects($this->once()) ->method('process') ->with($this->equalTo('crop')) - ->will($this->returnArgument(3)); + ->will($this->returnArgument(2)); // Cropping with height only should preserve the aspect ratio. - $width = $this->image->crop(0, 0, NULL, 50); - $this->assertEquals($width, 44); + $result = $this->image->crop(0, 0, NULL, 50); + $this->assertEquals($result['width'], 44); } /** @@ -337,9 +334,9 @@ public function testCrop() { $this->toolkit->expects($this->once()) ->method('process') ->with($this->equalTo('crop')) - ->will($this->returnArgument(3)); - $width = $this->image->crop(0, 0, 44, 50); - $this->assertEquals($width, 44); + ->will($this->returnArgument(2)); + $result = $this->image->crop(0, 0, 44, 50); + $this->assertEquals($result['width'], 44); } /** @@ -349,13 +346,13 @@ public function testResize() { $this->toolkit->expects($this->exactly(2)) ->method('process') ->with($this->equalTo('resize')) - ->will($this->returnArgument(1)); + ->will($this->returnArgument(2)); // Resize with integer for width and height. $this->image->resize(30, 40); // Pass a float for width. - $width = $this->image->resize(30.4, 40); + $result = $this->image->resize(30.4, 40); // Ensure that the float was rounded to an integer first. - $this->assertEquals($width, 30); + $this->assertEquals($result['width'], 30); } /**