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
61faea3c
Commit
61faea3c
authored
6 years ago
by
Vadim Justus
Browse files
Options
Downloads
Patches
Plain Diff
Fix integration tests
parent
34ab47fd
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
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.travis.yml
+1
-0
1 addition, 0 deletions
.travis.yml
Test/Integration/Model/BlockInstallerTest.php
+0
-168
0 additions, 168 deletions
Test/Integration/Model/BlockInstallerTest.php
Test/Integration/Model/PageInstallerTest.php
+0
-217
0 additions, 217 deletions
Test/Integration/Model/PageInstallerTest.php
with
1 addition
and
385 deletions
.travis.yml
+
1
−
0
View file @
61faea3c
...
...
@@ -33,6 +33,7 @@ before_install:
install
:
-
cd /tmp/magento
-
composer install --no-interaction
-
composer require --dev mikey179/vfsstream
script
:
-
php /tmp/magento/vendor/bin/phpunit -c /tmp/magento/app/code/Firegento/ContentProvisioning/Test/Integration/phpunit.travis.xml
This diff is collapsed.
Click to expand it.
Test/Integration/Model/BlockInstallerTest.php
deleted
100644 → 0
+
0
−
168
View file @
34ab47fd
<?php
declare
(
strict_types
=
1
);
namespace
Firegento\ContentProvisioning\Test\Integration\Model
;
use
Firegento\ContentProvisioning\Api\Data\BlockEntryInterface
;
use
Firegento\ContentProvisioning\Api\Data\BlockEntryInterfaceFactory
;
use
Firegento\ContentProvisioning\Model\BlockInstaller
;
use
Firegento\ContentProvisioning\Model\Query\GetBlockEntryList
;
use
Firegento\ContentProvisioning\Model\Query\GetFirstBlockByBlockEntry
;
use
Magento\Cms\Api\Data\BlockInterface
;
use
Magento\Framework\App\ResourceConnection
;
use
Magento\Store\Model\StoreManagerInterface
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
Magento\TestFramework\Helper\Bootstrap
;
class
BlockInstallerTest
extends
\PHPUnit\Framework\TestCase
{
/**
* @var BlockInstaller
*/
private
$installer
;
/**
* @var GetBlockEntryList|MockObject
*/
private
$getBlockEntryListMock
;
/**
* @var BlockEntryInterfaceFactory
*/
private
$blockEntryInterfaceFactory
;
/**
* @var StoreManagerInterface
*/
private
$storeManager
;
/**
* @var BlockEntryInterface[]
*/
private
$blockEntries
=
[];
/**
* @var GetFirstBlockByBlockEntry
*/
private
$getFirstBlockByBlockEntry
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
getBlockEntryListMock
=
self
::
getMockBuilder
(
GetBlockEntryList
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
installer
=
Bootstrap
::
getObjectManager
()
->
create
(
BlockInstaller
::
class
,
[
'getAllBlockEntries'
=>
$this
->
getBlockEntryListMock
]);
$this
->
blockEntryInterfaceFactory
=
Bootstrap
::
getObjectManager
()
->
create
(
BlockEntryInterfaceFactory
::
class
);
$this
->
storeManager
=
Bootstrap
::
getObjectManager
()
->
create
(
StoreManagerInterface
::
class
);
$this
->
getFirstBlockByBlockEntry
=
Bootstrap
::
getObjectManager
()
->
create
(
GetFirstBlockByBlockEntry
::
class
);
}
protected
function
tearDown
()
{
parent
::
tearDown
();
$connection
=
Bootstrap
::
getObjectManager
()
->
get
(
ResourceConnection
::
class
);
$connection
->
getConnection
()
->
delete
(
$connection
->
getTableName
(
'cms_block'
),
[
'identifier LIKE ?'
=>
'firegento-content-provisioning-test-%'
,
]
);
}
private
function
initBlockEntries
()
{
$this
->
blockEntries
[
1
]
=
$this
->
blockEntryInterfaceFactory
->
create
([
'data'
=>
[
BlockEntryInterface
::
TITLE
=>
'Test Block 1'
,
BlockEntryInterface
::
CONTENT
=>
'<h2>test foobar Aenean commodo ligula eget dolor aenean massa</h2>'
,
BlockEntryInterface
::
KEY
=>
'test.block.1'
,
BlockEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-1'
,
BlockEntryInterface
::
IS_ACTIVE
=>
false
,
BlockEntryInterface
::
IS_MAINTAINED
=>
true
,
BlockEntryInterface
::
STORES
=>
[
'admin'
],
]]);
$this
->
blockEntries
[
2
]
=
$this
->
blockEntryInterfaceFactory
->
create
([
'data'
=>
[
BlockEntryInterface
::
TITLE
=>
'Test Block 2'
,
BlockEntryInterface
::
CONTENT
=>
file_get_contents
(
__DIR__
.
'/_files/dummy-content.html'
),
BlockEntryInterface
::
KEY
=>
'test.block.2'
,
BlockEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-2'
,
BlockEntryInterface
::
IS_ACTIVE
=>
true
,
BlockEntryInterface
::
IS_MAINTAINED
=>
false
,
BlockEntryInterface
::
STORES
=>
[
'default'
,
'admin'
],
]]);
$this
->
getBlockEntryListMock
->
method
(
'get'
)
->
willReturn
(
$this
->
blockEntries
);
}
private
function
compareBlockWithEntryForStore
(
$entryIndex
)
{
$entry
=
$this
->
blockEntries
[
$entryIndex
];
$block
=
$this
->
getBlockByBlockEntry
(
$entry
);
$this
->
assertSame
(
$block
->
getTitle
(),
$entry
->
getTitle
());
$this
->
assertSame
(
$block
->
getContent
(),
$entry
->
getContent
());
$this
->
assertSame
(
$block
->
isActive
(),
$entry
->
isActive
());
}
/**
* @param BlockEntryInterface $entry
* @return BlockInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
private
function
getBlockByBlockEntry
(
BlockEntryInterface
$entry
):
BlockInterface
{
return
$this
->
getFirstBlockByBlockEntry
->
execute
(
$entry
);
}
public
function
testInstall
()
{
$this
->
initBlockEntries
();
$this
->
installer
->
install
();
// Verify, that block are in database like defined
$this
->
compareBlockWithEntryForStore
(
1
);
$this
->
compareBlockWithEntryForStore
(
2
);
}
public
function
testInstallUpdateMaintainedBlocks
()
{
$this
->
initBlockEntries
();
$this
->
installer
->
install
();
// Change block entry values
$this
->
blockEntries
[
1
]
->
setTitle
(
'Changed Block 1'
);
$this
->
blockEntries
[
1
]
->
setIsActive
(
true
);
$this
->
blockEntries
[
1
]
->
setContent
(
'New Content'
);
$this
->
blockEntries
[
2
]
->
setTitle
(
'Changed Block 2'
);
$this
->
blockEntries
[
2
]
->
setIsActive
(
true
);
$this
->
blockEntries
[
2
]
->
setContent
(
'New Content'
);
// Execute installer a second time
$this
->
installer
->
install
();
// Verify that first block was updated
$this
->
compareBlockWithEntryForStore
(
1
);
// Verify that second block did not change
$entry
=
$this
->
blockEntries
[
2
];
$block
=
$this
->
getBlockByBlockEntry
(
$entry
);
$this
->
assertNotSame
(
$block
->
getTitle
(),
$entry
->
getTitle
());
$this
->
assertNotSame
(
$block
->
getContent
(),
$entry
->
getContent
());
}
}
This diff is collapsed.
Click to expand it.
Test/Integration/Model/PageInstallerTest.php
deleted
100644 → 0
+
0
−
217
View file @
34ab47fd
<?php
declare
(
strict_types
=
1
);
namespace
Firegento\ContentProvisioning\Test\Integration\Model
;
use
Firegento\ContentProvisioning\Api\Data\PageEntryInterface
;
use
Firegento\ContentProvisioning\Api\Data\PageEntryInterfaceFactory
;
use
Firegento\ContentProvisioning\Model\PageInstaller
;
use
Firegento\ContentProvisioning\Model\Query\GetFirstPageByPageEntry
;
use
Firegento\ContentProvisioning\Model\Query\GetPageEntryList
;
use
Magento\Cms\Api\Data\PageInterface
;
use
Magento\Framework\App\ResourceConnection
;
use
Magento\Store\Model\StoreManagerInterface
;
use
PHPUnit\Framework\MockObject\MockObject
;
use
Magento\TestFramework\Helper\Bootstrap
;
class
PageInstallerTest
extends
\PHPUnit\Framework\TestCase
{
/**
* @var StoreManagerInterface
*/
private
$storeManager
;
/**
* @var GetPageEntryList|MockObject
*/
private
$getPageEntryListMock
;
/**
* @var PageInstaller
*/
private
$installer
;
/**
* @var PageEntryInterfaceFactory
*/
private
$pageEntryInterfaceFactory
;
/**
* @var PageEntryInterface[]
*/
private
$pageEntries
;
/**
* @var GetFirstPageByPageEntry
*/
private
$getFisrtPageByPageEntry
;
protected
function
setUp
()
{
parent
::
setUp
();
$this
->
getPageEntryListMock
=
self
::
getMockBuilder
(
GetPageEntryList
::
class
)
->
disableOriginalConstructor
()
->
getMock
();
$this
->
installer
=
Bootstrap
::
getObjectManager
()
->
create
(
PageInstaller
::
class
,
[
'getAllPageEntries'
=>
$this
->
getPageEntryListMock
]);
$this
->
pageEntryInterfaceFactory
=
Bootstrap
::
getObjectManager
()
->
create
(
PageEntryInterfaceFactory
::
class
);
$this
->
storeManager
=
Bootstrap
::
getObjectManager
()
->
create
(
StoreManagerInterface
::
class
);
$this
->
getFisrtPageByPageEntry
=
Bootstrap
::
getObjectManager
()
->
create
(
GetFirstPageByPageEntry
::
class
);
}
protected
function
tearDown
()
{
parent
::
tearDown
();
$connection
=
Bootstrap
::
getObjectManager
()
->
get
(
ResourceConnection
::
class
);
$connection
->
getConnection
()
->
delete
(
$connection
->
getTableName
(
'cms_page'
),
[
'identifier LIKE ?'
=>
'firegento-content-provisioning-test-%'
,
]
);
$connection
->
getConnection
()
->
delete
(
$connection
->
getTableName
(
'url_rewrite'
),
[
'request_path LIKE ?'
=>
'firegento-content-provisioning-test-%'
,
'entity_type = ?'
=>
'cms-page'
,
]
);
}
private
function
initEntries
()
{
$this
->
pageEntries
[
1
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Test Page 1'
,
PageEntryInterface
::
CONTENT
=>
'<h2>test foobar Aenean commodo ligula eget dolor aenean massa</h2>'
,
PageEntryInterface
::
CONTENT_HEADING
=>
'Some Content Heading'
,
PageEntryInterface
::
KEY
=>
'test.page.1'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-1'
,
PageEntryInterface
::
IS_ACTIVE
=>
false
,
PageEntryInterface
::
IS_MAINTAINED
=>
true
,
PageEntryInterface
::
STORES
=>
[
'admin'
],
PageEntryInterface
::
META_DESCRIPTION
=>
'Some seo description'
,
PageEntryInterface
::
META_KEYWORDS
=>
'Some, seo, keywords'
,
PageEntryInterface
::
META_TITLE
=>
'Seo title'
,
PageEntryInterface
::
PAGE_LAYOUT
=>
'3columns'
,
PageEntryInterface
::
LAYOUT_UPDATE_XML
=>
'<foo>bar</foo>'
,
PageEntryInterface
::
CUSTOM_THEME
=>
3
,
PageEntryInterface
::
CUSTOM_THEME_FROM
=>
'2019-03-29'
,
PageEntryInterface
::
CUSTOM_THEME_TO
=>
'2019-05-29'
,
PageEntryInterface
::
CUSTOM_ROOT_TEMPLATE
=>
'3columns'
,
]]);
$this
->
pageEntries
[
2
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Test Page 2'
,
PageEntryInterface
::
CONTENT
=>
file_get_contents
(
__DIR__
.
'/_files/dummy-content.html'
),
PageEntryInterface
::
CONTENT_HEADING
=>
'Some Content Heading'
,
PageEntryInterface
::
KEY
=>
'test.page.2'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-2'
,
PageEntryInterface
::
IS_ACTIVE
=>
true
,
PageEntryInterface
::
IS_MAINTAINED
=>
false
,
PageEntryInterface
::
STORES
=>
[
'default'
,
'admin'
],
]]);
$this
->
pageEntries
[
3
]
=
$this
->
pageEntryInterfaceFactory
->
create
([
'data'
=>
[
PageEntryInterface
::
TITLE
=>
'Test Page 3'
,
PageEntryInterface
::
CONTENT
=>
'<h2>test foobar Aenean commodo ligula eget dolor aenean massa</h2>'
,
PageEntryInterface
::
CONTENT_HEADING
=>
'Some Content Heading'
,
PageEntryInterface
::
KEY
=>
'test.page.3'
,
PageEntryInterface
::
IDENTIFIER
=>
'firegento-content-provisioning-test-3'
,
PageEntryInterface
::
IS_ACTIVE
=>
true
,
PageEntryInterface
::
IS_MAINTAINED
=>
true
,
PageEntryInterface
::
STORES
=>
[
'default'
],
PageEntryInterface
::
META_DESCRIPTION
=>
'Some seo description'
,
PageEntryInterface
::
META_KEYWORDS
=>
'Some, seo, keywords'
,
PageEntryInterface
::
META_TITLE
=>
'Seo title'
,
PageEntryInterface
::
PAGE_LAYOUT
=>
'3columns'
,
PageEntryInterface
::
LAYOUT_UPDATE_XML
=>
'<foo>bar</foo>'
]]);
$this
->
getPageEntryListMock
->
method
(
'get'
)
->
willReturn
(
$this
->
pageEntries
);
}
private
function
comparePageWithEntryForStore
(
$entryIndex
)
{
$entry
=
$this
->
pageEntries
[
$entryIndex
];
$block
=
$this
->
getPageByPageEntry
(
$entry
);
$this
->
assertSame
(
$block
->
getTitle
(),
$entry
->
getTitle
());
$this
->
assertSame
(
$block
->
getContent
(),
$entry
->
getContent
());
$this
->
assertSame
(
$block
->
isActive
(),
$entry
->
isActive
());
$this
->
assertSame
(
$block
->
getMetaDescription
(),
$entry
->
getMetaDescription
());
$this
->
assertSame
(
$block
->
getMetaKeywords
(),
$entry
->
getMetaKeywords
());
$this
->
assertSame
(
$block
->
getMetaTitle
(),
$entry
->
getMetaTitle
());
$this
->
assertSame
(
$block
->
getCustomLayoutUpdateXml
(),
$entry
->
getCustomLayoutUpdateXml
());
$this
->
assertSame
(
$block
->
getPageLayout
(),
$entry
->
getPageLayout
());
$this
->
assertSame
(
$block
->
getContentHeading
(),
$entry
->
getContentHeading
());
}
/**
* @param PageEntryInterface $entry
* @return PageInterface
* @throws \Magento\Framework\Exception\NoSuchEntityException
* @throws \Magento\Framework\Exception\LocalizedException
*/
private
function
getPageByPageEntry
(
PageEntryInterface
$entry
):
PageInterface
{
return
$this
->
getFisrtPageByPageEntry
->
execute
(
$entry
);
}
public
function
testInstall
()
{
$this
->
initEntries
();
$this
->
installer
->
install
();
// Verify, that pages are in database like defined
$this
->
comparePageWithEntryForStore
(
1
);
$this
->
comparePageWithEntryForStore
(
2
);
$this
->
comparePageWithEntryForStore
(
3
);
}
public
function
testInstallUpdateMaintainedPages
()
{
$this
->
initEntries
();
$this
->
installer
->
install
();
// Change page entry values
$this
->
pageEntries
[
1
]
->
setTitle
(
'Changed Page 1'
);
$this
->
pageEntries
[
1
]
->
setIsActive
(
true
);
$this
->
pageEntries
[
1
]
->
setContent
(
'New Content'
);
$this
->
pageEntries
[
2
]
->
setTitle
(
'Changed Page 2'
);
$this
->
pageEntries
[
2
]
->
setIsActive
(
true
);
$this
->
pageEntries
[
2
]
->
setContent
(
'New Content'
);
$this
->
pageEntries
[
3
]
->
setTitle
(
'Changed Page 3'
);
$this
->
pageEntries
[
3
]
->
setContent
(
'New Content 333'
);
$this
->
pageEntries
[
3
]
->
setMetaDescription
(
'New Meta description'
);
$this
->
pageEntries
[
3
]
->
setPageLayout
(
'1column'
);
$this
->
pageEntries
[
3
]
->
setContentHeading
(
'Another Content Heading'
);
// Execute installer a second time
$this
->
installer
->
install
();
// Verify that first and third page was updated
$this
->
comparePageWithEntryForStore
(
1
);
$this
->
comparePageWithEntryForStore
(
3
);
// Verify that second page did not change
$entry
=
$this
->
pageEntries
[
2
];
$block
=
$this
->
getPageByPageEntry
(
$entry
);
$this
->
assertNotSame
(
$block
->
getTitle
(),
$entry
->
getTitle
());
$this
->
assertNotSame
(
$block
->
getContent
(),
$entry
->
getContent
());
}
}
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