Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Platform
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
Administrator
Platform
Commits
ad5489d5
Commit
ad5489d5
authored
Oct 31, 2014
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Abstracting the destination file in test
parent
fbe604cb
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
12 deletions
+25
-12
ImagyTest.php
Tests/ImagyTest.php
+25
-12
No files found.
Tests/ImagyTest.php
View file @
ad5489d5
...
...
@@ -16,41 +16,54 @@ class ImagyTest extends BaseTestCase
* @var \Illuminate\Filesystem\Filesystem
*/
protected
$finder
;
/**
* @var \Illuminate\Contracts\Config\Repository
*/
protected
$config
;
/**
* @var string
*/
protected
$mediaPath
;
/**
*
*/
public
function
setUp
()
{
parent
::
setUp
();
$config
=
App
::
make
(
'Illuminate\Contracts\Config\Repository'
);
$
this
->
config
=
App
::
make
(
'Illuminate\Contracts\Config\Repository'
);
$module
=
App
::
make
(
'Pingpong\Modules\Module'
);
$this
->
finder
=
App
::
make
(
'Illuminate\Filesystem\Filesystem'
);
$this
->
imagy
=
new
Imagy
(
new
InterventionFactory
,
new
ThumbnailsManager
(
$config
,
$module
),
$config
);
$this
->
imagy
=
new
Imagy
(
new
InterventionFactory
,
new
ThumbnailsManager
(
$this
->
config
,
$module
),
$this
->
config
);
$this
->
mediaPath
=
$this
->
config
->
get
(
'media::config.files-path'
);
}
/** @test */
public
function
it_should_create_a_file
()
{
if
(
$this
->
finder
->
isFile
(
public_path
()
.
'/assets/media/google-map_smallThumb.png'
))
{
$this
->
finder
->
delete
(
public_path
()
.
'/assets/media/google-map_smallThumb.png'
);
if
(
$this
->
finder
->
isFile
(
public_path
()
.
"
{
$this
->
mediaPath
}
google-map_smallThumb.png"
))
{
$this
->
finder
->
delete
(
public_path
()
.
"
{
$this
->
mediaPath
}
google-map_smallThumb.png"
);
}
$this
->
imagy
->
get
(
'/assets/media/google-map.png'
,
'smallThumb'
,
true
);
$this
->
imagy
->
get
(
"
{
$this
->
mediaPath
}
google-map.png"
,
'smallThumb'
,
true
);
$this
->
assertTrue
(
$this
->
finder
->
isFile
(
public_path
()
.
'/assets/media/google-map_smallThumb.png'
));
$this
->
assertTrue
(
$this
->
finder
->
isFile
(
public_path
()
.
"
{
$this
->
mediaPath
}
google-map_smallThumb.png"
));
}
/** @test */
public
function
it_should_not_create_thumbs_for_pdf_files
()
{
$this
->
imagy
->
get
(
'/assets/media/test-pdf.pdf'
,
'smallThumb'
,
true
);
$this
->
imagy
->
get
(
"
{
$this
->
mediaPath
}
test-pdf.pdf"
,
'smallThumb'
,
true
);
$this
->
assertFalse
(
$this
->
finder
->
isFile
(
public_path
()
.
'/assets/media/test-pdf_smallThumb.png'
));
$this
->
assertFalse
(
$this
->
finder
->
isFile
(
public_path
()
.
"
{
$this
->
mediaPath
}
test-pdf_smallThumb.png"
));
}
/** @test */
public
function
it_should_return_thumbnail_path
()
{
$path
=
$this
->
imagy
->
getThumbnail
(
'/assets/media/google-map.png'
,
'smallThumb'
);
$expected
=
'/assets/media/google-map_smallThumb.png'
;
$path
=
$this
->
imagy
->
getThumbnail
(
"
{
$this
->
mediaPath
}
google-map.png"
,
'smallThumb'
);
$expected
=
"
{
$this
->
mediaPath
}
google-map_smallThumb.png"
;
$this
->
assertEquals
(
$expected
,
$path
);
}
...
...
@@ -58,8 +71,8 @@ class ImagyTest extends BaseTestCase
/** @test */
public
function
it_should_return_same_path_for_non_images
()
{
$path
=
$this
->
imagy
->
getThumbnail
(
'/assets/media/test-pdf.pdf'
,
'smallThumb'
);
$expected
=
'/assets/media/test-pdf.pdf'
;
$path
=
$this
->
imagy
->
getThumbnail
(
"
{
$this
->
mediaPath
}
test-pdf.pdf"
,
'smallThumb'
);
$expected
=
"
{
$this
->
mediaPath
}
test-pdf.pdf"
;
$this
->
assertEquals
(
$expected
,
$path
);
}
...
...
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