/** * Tests the JImage::rotate() method. To test this we create an image that contains a red * horizontal line in the middle of the image, and a white vertical line in the middle of the * image. Once the image is rotated 90 degrees we test the end points of the lines to ensure that * the colors have swapped. * * @return void * * @since 11.3 */ public function testRotate() { // Create a image handle of the correct size. $imageHandle = imagecreatetruecolor(101, 101); // Define red and white. $red = imagecolorallocate($imageHandle, 255, 0, 0); $white = imagecolorallocate($imageHandle, 255, 255, 255); // Draw a red horizontal line in the middle of the image. imageline($imageHandle, 5, 50, 95, 50, $red); // Draw a white vertical line in the middle of the image. imageline($imageHandle, 50, 5, 50, 95, $white); // Create a new JImageInspector from the image handle. $image = new JImageInspector($imageHandle); // Crop the image to specifications. $image->rotate(90, -1, false); // Validate the correct pixels for the ends of the lines. // Red line. $this->assertEquals($red, imagecolorat($image->getClassProperty('handle'), 50, 5)); $this->assertEquals($red, imagecolorat($image->getClassProperty('handle'), 50, 95)); // White line. $this->assertEquals($white, imagecolorat($image->getClassProperty('handle'), 5, 50)); $this->assertEquals($white, imagecolorat($image->getClassProperty('handle'), 95, 50)); }