Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,18 @@ public function testSearch()
);
}

/**
* 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);
}

/**
* @return PageInterface[]
*/
Expand Down Expand Up @@ -316,4 +328,55 @@ private function prepareCmsPages()

return $result;
}

/**
* 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]);
}
}