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
bdf1e884
Unverified
Commit
bdf1e884
authored
Sep 26, 2017
by
Nicolas Widart
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Testing the ability to remove files + files in subfolders
parent
a5fce0e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
33 additions
and
3 deletions
+33
-3
Imagy.php
Modules/Media/Image/Imagy.php
+3
-3
ImagyTest.php
Modules/Media/Tests/ImagyTest.php
+30
-0
No files found.
Modules/Media/Image/Imagy.php
View file @
bdf1e884
...
@@ -206,10 +206,10 @@ class Imagy
...
@@ -206,10 +206,10 @@ class Imagy
}
}
$paths
[]
=
$this
->
getDestinationPath
(
$file
->
path
->
getRelativeUrl
());
$paths
[]
=
$this
->
getDestinationPath
(
$file
->
path
->
getRelativeUrl
());
$fileName
=
pathinfo
(
$file
->
path
,
PATHINFO_FILENAME
);
$extension
=
pathinfo
(
$file
->
path
,
PATHINFO_EXTENSION
);
foreach
(
$this
->
manager
->
all
()
as
$thumbnail
)
{
foreach
(
$this
->
manager
->
all
()
as
$thumbnail
)
{
$path
=
config
(
'asgard.media.config.files-path'
)
.
"
{
$fileName
}
_
{
$thumbnail
->
name
()
}
.
{
$extension
}
"
;
$path
=
$this
->
getFilenameFor
(
$file
->
path
,
$thumbnail
);
if
(
$this
->
fileExists
(
$this
->
getDestinationPath
(
$path
)))
{
if
(
$this
->
fileExists
(
$this
->
getDestinationPath
(
$path
)))
{
$paths
[]
=
(
new
MediaPath
(
$this
->
getDestinationPath
(
$path
)))
->
getRelativeUrl
();
$paths
[]
=
(
new
MediaPath
(
$this
->
getDestinationPath
(
$path
)))
->
getRelativeUrl
();
}
}
...
...
Modules/Media/Tests/ImagyTest.php
View file @
bdf1e884
...
@@ -108,6 +108,36 @@ class ImagyTest extends MediaTestCase
...
@@ -108,6 +108,36 @@ class ImagyTest extends MediaTestCase
$this
->
assertEquals
(
$expected
,
$smallThumbPath
);
$this
->
assertEquals
(
$expected
,
$smallThumbPath
);
}
}
/** @test */
public
function
it_can_delete_thumbnail_files
()
{
$this
->
resetDatabase
();
$file
=
\Illuminate\Http\UploadedFile
::
fake
()
->
image
(
'my-file.jpg'
);
$file
=
app
(
FileService
::
class
)
->
store
(
$file
);
$this
->
assertCount
(
3
,
$this
->
app
[
'files'
]
->
allFiles
(
public_path
(
config
(
'asgard.media.config.files-path'
))));
$this
->
imagy
->
deleteAllFor
(
$file
);
$this
->
assertCount
(
0
,
$this
->
app
[
'files'
]
->
allFiles
(
public_path
(
config
(
'asgard.media.config.files-path'
))));
}
/** @test */
public
function
it_can_delete_thumbnail_files_in_subdirectory
()
{
$this
->
resetDatabase
();
app
(
FolderRepository
::
class
)
->
create
([
'name'
=>
'My Folder'
,
'parent_id'
=>
0
]);
$file
=
\Illuminate\Http\UploadedFile
::
fake
()
->
image
(
'my-file.jpg'
);
$file
=
app
(
FileService
::
class
)
->
store
(
$file
,
1
);
$path
=
public_path
(
config
(
'asgard.media.config.files-path'
)
.
'my-folder/'
);
$this
->
assertCount
(
3
,
$this
->
app
[
'files'
]
->
allFiles
(
$path
));
$this
->
imagy
->
deleteAllFor
(
$file
);
$this
->
assertCount
(
0
,
$this
->
app
[
'files'
]
->
allFiles
(
$path
));
}
/** @test */
/** @test */
public
function
it_should_return_same_path_for_non_images
()
public
function
it_should_return_same_path_for_non_images
()
{
{
...
...
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