Commit 35373b14 by Qiang Xue

fixed test breaks.

parent afbcae0c
......@@ -190,7 +190,8 @@ class BaseImage
$img = static::getImagine()->open(Yii::getAlias($filename));
$watermark = static::getImagine()->open(Yii::getAlias($watermarkFilename));
return $img->paste($watermark, new Point($start[0], $start[1]));
$img->paste($watermark, new Point($start[0], $start[1]));
return $img;
}
/**
......@@ -221,7 +222,9 @@ class BaseImage
$img = static::getImagine()->open(Yii::getAlias($filename));
$font = static::getImagine()->font(Yii::getAlias($fontFile), $fontSize, new Color($fontColor));
return $img->draw()->text($text, $font, new Point($start[0], $start[1]), $fontAngle);
$img->draw()->text($text, $font, new Point($start[0], $start[1]), $fontAngle);
return $img;
}
/**
......@@ -245,6 +248,8 @@ class BaseImage
$image = static::getImagine()->create($box, $padColor);
return $image->paste($img, $pasteTo);
$image->paste($img, $pasteTo);
return $image;
}
}
......@@ -19,6 +19,10 @@ class VendorTestCase extends TestCase
public static function setUpBeforeClass()
{
$vendorDir = __DIR__ . '/../../vendor';
if (!is_dir($vendorDir)) {
// this is used by `yii2-dev`
$vendorDir = __DIR__ . '/../../../../../vendor';
}
Yii::setAlias('@vendor', $vendorDir);
$vendorAutoload = $vendorDir . '/autoload.php';
if (file_exists($vendorAutoload)) {
......
......@@ -38,8 +38,7 @@ abstract class AbstractImageTest extends VendorTestCase
$fontFile = Yii::getAlias('@yiiunit/data/imagine/GothamRnd-Light') . '.otf';
$img = Image::text($this->imageFile, 'Yii-2 Image', [
'font' => $fontFile,
$img = Image::text($this->imageFile, 'Yii-2 Image', $fontFile, [0, 0], [
'size' => 12,
'color' => '000'
]);
......@@ -57,11 +56,6 @@ abstract class AbstractImageTest extends VendorTestCase
$this->assertEquals(100, $img->getSize()->getWidth());
$this->assertEquals(100, $img->getSize()->getHeight());
$point = new Point(20, 20);
$img = Image::crop($this->imageFile, 100, 100, $point);
$this->assertEquals(100, $img->getSize()->getWidth());
$this->assertEquals(100, $img->getSize()->getHeight());
}
public function testWatermark()
......@@ -97,24 +91,8 @@ abstract class AbstractImageTest extends VendorTestCase
{
Image::setImagine(null);
Image::$driver = 'fake-driver';
Image::getImagine();
}
/**
* @expectedException \InvalidArgumentException
*/
public function testShouldThrowExceptionOnCropInvalidArgument()
{
Image::crop($this->imageFile, 100, 100, new \stdClass());
}
/**
* @expectedException \InvalidArgumentException
*/
public function testShouldThrowExceptionOnWatermarkInvalidArgument()
{
Image::watermark($this->imageFile, $this->watermarkFile, new \stdClass());
}
abstract protected function isFontTestSupported();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment