Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
M2 content provisioning
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
TechDivision Public
M2 content provisioning
Commits
d977ce79
Commit
d977ce79
authored
6 years ago
by
Vadim Justus
Browse files
Options
Downloads
Patches
Plain Diff
Integrate test for media file installer
parent
2846605c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!14
Introduce logic for handling with media files
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Model/Command/ApplyMediaFiles.php
+1
-1
1 addition, 1 deletion
Model/Command/ApplyMediaFiles.php
Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php
+144
-0
144 additions, 0 deletions
...Integration/Model/PageInstaller/InstallMediaFilesTest.php
with
145 additions
and
1 deletion
Model/Command/ApplyMediaFiles.php
+
1
−
1
View file @
d977ce79
...
...
@@ -51,7 +51,7 @@ class ApplyMediaFiles
$sourceInfo
=
new
SplFileInfo
(
$sourcePathname
);
if
(
$sourceInfo
->
isFile
()
&&
$sourceInfo
->
isReadable
())
{
$this
->
createDirectory
(
$targetDirPath
,
$sourceDirPath
,
$sourceInfo
);
copy
(
$sourceInfo
->
get
Real
Path
(),
$targetPathname
);
copy
(
$sourceInfo
->
getPath
name
(),
$targetPathname
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Test/Integration/Model/PageInstaller/InstallMediaFilesTest.php
0 → 100644
+
144
−
0
View file @
d977ce79
<?php
declare
(
strict_types
=
1
);
namespace
Firegento\ContentProvisioning\Test\Integration\Model\PageInstaller
;
use
Firegento\ContentProvisioning\Api\Data\PageEntryInterface
;
use
Firegento\ContentProvisioning\Api\TargetMediaDirectoryPathProviderInterface
;
use
Firegento\ContentProvisioning\Model\Command\ApplyMediaFiles
;
use
Magento\TestFramework\Helper\Bootstrap
;
use
Firegento\ContentProvisioning\Model\PageInstaller
;
use
org\bovigo\vfs\vfsStream
;
use
org\bovigo\vfs\vfsStreamDirectory
;
use
PHPUnit\Framework\MockObject\MockObject
;
class
InstallMediaFilesTest
extends
TestCase
{
/**
* @var TargetMediaDirectoryPathProviderInterface|MockObject
*/
protected
$targetMediaDirectoryPathProvider
;
/**
* @var vfsStreamDirectory
*/
protected
$fileSystem
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
targetMediaDirectoryPathProvider
=
self
::
getMockBuilder
(
TargetMediaDirectoryPathProviderInterface
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$structure
=
[
'source'
=>
[
'media'
=>
[
'file-1.png'
=>
'some value'
,
'file-2.txt'
=>
'some value'
,
'not-used.png'
=>
'some value'
,
'sub-directory'
=>
[
'file-3.jpg'
=>
'some value'
],
'existing'
=>
[
'file-4.gif'
=>
'some value'
]
]
],
'pub'
=>
[
'media'
=>
[
'existing'
=>
[]
]
],
];
$this
->
fileSystem
=
vfsStream
::
setup
(
'root'
,
null
,
$structure
);
$this
->
targetMediaDirectoryPathProvider
->
method
(
'get'
)
->
willReturn
(
$this
->
fileSystem
->
getChild
(
'pub/media'
)
->
url
()
);
$applyMediaFiles
=
Bootstrap
::
getObjectManager
()
->
create
(
ApplyMediaFiles
::
class
,
[
'targetMediaDirectoryPathProvider'
=>
$this
->
targetMediaDirectoryPathProvider
,
]);
$this
->
installer
=
Bootstrap
::
getObjectManager
()
->
create
(
PageInstaller
::
class
,
[
'getAllPageEntries'
=>
$this
->
getPageEntryListMock
,
'applyMediaFiles'
=>
$applyMediaFiles
]);
}
protected
function
initEntries
()
{
$this
->
pageEntries
[
1
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Page with images 1'
,
PageEntryInterface
::
CONTENT
=>
''
,
PageEntryInterface
::
CONTENT_HEADING
=>
'Some Content Heading'
,
PageEntryInterface
::
KEY
=>
'page.with.images.1'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-images-1'
,
PageEntryInterface
::
IS_ACTIVE
=>
true
,
PageEntryInterface
::
IS_MAINTAINED
=>
true
,
PageEntryInterface
::
STORES
=>
[
'admin'
],
PageEntryInterface
::
MEDIA_DIRECTORY
=>
$this
->
fileSystem
->
getChild
(
'source/media'
)
->
url
(),
PageEntryInterface
::
MEDIA_FILES
=>
[
'sub-directory/file-3.jpg'
,
'file-1.png'
,
]
]]);
$this
->
pageEntries
[
2
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Page with images 2'
,
PageEntryInterface
::
CONTENT
=>
''
,
PageEntryInterface
::
CONTENT_HEADING
=>
''
,
PageEntryInterface
::
KEY
=>
'page.with.images.2'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-images-2'
,
PageEntryInterface
::
IS_ACTIVE
=>
true
,
PageEntryInterface
::
IS_MAINTAINED
=>
true
,
PageEntryInterface
::
STORES
=>
[
'admin'
],
PageEntryInterface
::
MEDIA_DIRECTORY
=>
$this
->
fileSystem
->
getChild
(
'source/media'
)
->
url
(),
PageEntryInterface
::
MEDIA_FILES
=>
[
'file-2.txt'
,
'existing/file-4.gif'
,
]
]]);
$this
->
pageEntries
[
3
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Page with images 3'
,
PageEntryInterface
::
CONTENT
=>
''
,
PageEntryInterface
::
CONTENT_HEADING
=>
''
,
PageEntryInterface
::
KEY
=>
'page.with.images.3'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-images-3'
,
PageEntryInterface
::
IS_ACTIVE
=>
true
,
PageEntryInterface
::
IS_MAINTAINED
=>
true
,
PageEntryInterface
::
STORES
=>
[
'admin'
],
PageEntryInterface
::
MEDIA_DIRECTORY
=>
$this
->
fileSystem
->
getChild
(
'source/media'
)
->
url
(),
PageEntryInterface
::
MEDIA_FILES
=>
[
'sub-directory/file-3.jpg'
,
'file-1.png'
,
'not-existing/image.png'
,
]
]]);
$this
->
getPageEntryListMock
->
method
(
'get'
)
->
willReturn
(
$this
->
pageEntries
);
}
public
function
testInstall
()
{
$this
->
initEntries
();
$this
->
installer
->
install
();
$this
->
assertTrue
(
$this
->
fileSystem
->
hasChild
(
'pub/media/file-1.png'
));
$this
->
assertTrue
(
$this
->
fileSystem
->
hasChild
(
'pub/media/file-2.txt'
));
$this
->
assertTrue
(
$this
->
fileSystem
->
hasChild
(
'pub/media/sub-directory/file-3.jpg'
));
$this
->
assertTrue
(
$this
->
fileSystem
->
hasChild
(
'pub/media/existing/file-4.gif'
));
$this
->
assertFalse
(
$this
->
fileSystem
->
hasChild
(
'pub/media/not-used.png'
));
$this
->
assertFalse
(
$this
->
fileSystem
->
hasChild
(
'pub/media/not-existing'
));
$this
->
assertFalse
(
$this
->
fileSystem
->
hasChild
(
'pub/media/not-existing/image.png'
));
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment