Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
35373b14
Commit
35373b14
authored
Jan 01, 2014
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixed test breaks.
parent
afbcae0c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
27 deletions
+14
-27
BaseImage.php
extensions/yii/imagine/BaseImage.php
+8
-3
VendorTestCase.php
tests/unit/VendorTestCase.php
+4
-0
AbstractImageTest.php
tests/unit/extensions/imagine/AbstractImageTest.php
+2
-24
No files found.
extensions/yii/imagine/BaseImage.php
View file @
35373b14
...
...
@@ -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
;
}
}
tests/unit/VendorTestCase.php
View file @
35373b14
...
...
@@ -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
))
{
...
...
tests/unit/extensions/imagine/AbstractImageTest.php
View file @
35373b14
...
...
@@ -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
();
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment