Skip to content

Commit

Permalink
MAGETWO-58383: [Backport] - [GitHub] Saving CMS page does not create …
Browse files Browse the repository at this point in the history
…URL rewrite in Magento 2.1.0 with single-store mode #5923 - for 2.1
  • Loading branch information
StasKozar committed Feb 8, 2018
1 parent a81b5ad commit 0f2832b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app/code/Magento/Cms/Controller/Adminhtml/Page/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ class Save extends \Magento\Backend\App\Action
* @param DataPersistorInterface $dataPersistor
* @param \Magento\Cms\Model\PageFactory $pageFactory
* @param \Magento\Cms\Api\PageRepositoryInterface $pageRepository
*
*/
public function __construct(
Action\Context $context,
Expand All @@ -62,6 +61,7 @@ public function __construct(
$this->pageRepository = $pageRepository
?: \Magento\Framework\App\ObjectManager::getInstance()
->get(\Magento\Cms\Api\PageRepositoryInterface::class);

parent::__construct($context);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function setUp()
'dataProcessor' => $this->dataProcessorMock,
'dataPersistor' => $this->dataPersistorMock,
'pageFactory' => $this->pageFactory,
'pageRepository' => $this->pageRepository
'pageRepository' => $this->pageRepository,
]
);
}
Expand Down Expand Up @@ -258,7 +258,9 @@ public function testSaveActionThrowsException()
->method('getId')
->willReturn(true);
$page->expects($this->once())->method('setData');
$this->pageRepository->expects($this->once())->method('save')->with($page)
$this->pageRepository->expects($this->once())
->method('save')
->with($page)
->willThrowException(new \Exception('Error message.'));

$this->messageManagerMock->expects($this->never())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
*/
namespace Magento\CmsUrlRewrite\Test\Unit\Model;


/**
* Test for \Magento\CmsUrlRewrite\Model\CmsPageUrlPathGenerator class.
*/
Expand Down Expand Up @@ -56,7 +55,7 @@ protected function setUp()
[
'storeManager' => $this->storeManager,
'urlRewriteFactory' => $this->urlRewriteFactory,
'cmsPageUrlPathGenerator' => $this->urlPathGenerator
'cmsPageUrlPathGenerator' => $this->urlPathGenerator,
]
);
}
Expand All @@ -69,6 +68,7 @@ public function testGenerateForAllStores()
$cmsPage = $this->getMockBuilder(\Magento\Cms\Model\Page::class)
->disableOriginalConstructor()
->getMock();

$cmsPage->expects($this->any())->method('getStores')->willReturn($initializesStores);
$store = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->setMethods(['getStoreId'])
Expand Down Expand Up @@ -96,6 +96,7 @@ public function testGenerateForSpecificStores()
$cmsPage = $this->getMockBuilder(\Magento\Cms\Model\Page::class)
->disableOriginalConstructor()
->getMock();

$cmsPage->expects($this->any())->method('getStores')->willReturn($initializesStores);
$firstStore = $this->getMockBuilder(\Magento\Store\Api\Data\StoreInterface::class)
->setMethods(['getStoreId'])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,14 @@ public function processAssert(
$errors = $this->verifyData($cmsFixtureData, $cmsFormData);
\PHPUnit_Framework_Assert::assertEmpty($errors, $errors);
}

/**
* CMS Page content equals to data from fixture.
*
* @return string
*/
public function toString()
{
return 'CMS Page content equals to data from fixture.';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,6 @@ public function processAssert(
*/
public function toString()
{
return 'CMS Page content equals to data from fixture.';
return "CMS Page content isn't displayed on frontend.";
}
}

0 comments on commit 0f2832b

Please sign in to comment.