Skip to content

Commit

Permalink
Merge pull request #1420 from magento-engcom/2.1-develop-prs
Browse files Browse the repository at this point in the history
[EngCom] Public Pull Requests - 2.1
 - MAGETWO-71658: Fix for url_rewrite on page delete via api #10569
  • Loading branch information
ishakhsuvarov authored Aug 17, 2017
2 parents 8d7aab7 + 22e2d0a commit e55bc07
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 0 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -249,4 +249,67 @@ public function testSearch()
$this->assertEquals(1, $searchResult['total_count']);
$this->assertEquals($searchResult['items'][0][PageInterface::IDENTIFIER], $pageIdentifier);
}

/**
* Create page with the same identifier after one was removed.
*/
public function testCreateSamePage()
{
$pageIdentifier = 'page-' . uniqid();

$pageId = $this->createPageWithIdentifier($pageIdentifier);
$this->deletePageByIdentifier($pageId);
$this->createPageWithIdentifier($pageIdentifier);
}

/**
* Create page with hard-coded identifier to test with create-delete-create flow.
* @param string $identifier
* @return string
*/
private function createPageWithIdentifier($identifier)
{
$serviceInfo = [
'rest' => [
'resourcePath' => self::RESOURCE_PATH,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'Save',
],
];
$requestData = ['page' =>
[
PageInterface::IDENTIFIER => $identifier,
PageInterface::TITLE => 'Page title',
],
];

$result = $this->_webApiCall($serviceInfo, $requestData);
return $result['id'];
}

/**
* Remove page with hard-coded-identifier
* @param string $pageId
* @return void
*/
private function deletePageByIdentifier($pageId)
{
$serviceInfo = [
'rest' => [
'resourcePath' => self::RESOURCE_PATH . '/' . $pageId,
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE,
],
'soap' => [
'service' => self::SERVICE_NAME,
'serviceVersion' => self::SERVICE_VERSION,
'operation' => self::SERVICE_NAME . 'DeleteById',
],
];

$this->_webApiCall($serviceInfo, [PageInterface::PAGE_ID => $pageId]);
}
}

0 comments on commit e55bc07

Please sign in to comment.