Skip to content

Commit e55bc07

Browse files
Merge pull request #1420 from magento-engcom/2.1-develop-prs
[EngCom] Public Pull Requests - 2.1 - MAGETWO-71658: Fix for url_rewrite on page delete via api #10569
2 parents 8d7aab7 + 22e2d0a commit e55bc07

File tree

2 files changed

+63
-0
lines changed

2 files changed

+63
-0
lines changed

dev/tests/api-functional/testsuite/Magento/Cms/Api/PageRepositoryTest.php

+63
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,67 @@ public function testSearch()
249249
$this->assertEquals(1, $searchResult['total_count']);
250250
$this->assertEquals($searchResult['items'][0][PageInterface::IDENTIFIER], $pageIdentifier);
251251
}
252+
253+
/**
254+
* Create page with the same identifier after one was removed.
255+
*/
256+
public function testCreateSamePage()
257+
{
258+
$pageIdentifier = 'page-' . uniqid();
259+
260+
$pageId = $this->createPageWithIdentifier($pageIdentifier);
261+
$this->deletePageByIdentifier($pageId);
262+
$this->createPageWithIdentifier($pageIdentifier);
263+
}
264+
265+
/**
266+
* Create page with hard-coded identifier to test with create-delete-create flow.
267+
* @param string $identifier
268+
* @return string
269+
*/
270+
private function createPageWithIdentifier($identifier)
271+
{
272+
$serviceInfo = [
273+
'rest' => [
274+
'resourcePath' => self::RESOURCE_PATH,
275+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
276+
],
277+
'soap' => [
278+
'service' => self::SERVICE_NAME,
279+
'serviceVersion' => self::SERVICE_VERSION,
280+
'operation' => self::SERVICE_NAME . 'Save',
281+
],
282+
];
283+
$requestData = ['page' =>
284+
[
285+
PageInterface::IDENTIFIER => $identifier,
286+
PageInterface::TITLE => 'Page title',
287+
],
288+
];
289+
290+
$result = $this->_webApiCall($serviceInfo, $requestData);
291+
return $result['id'];
292+
}
293+
294+
/**
295+
* Remove page with hard-coded-identifier
296+
* @param string $pageId
297+
* @return void
298+
*/
299+
private function deletePageByIdentifier($pageId)
300+
{
301+
$serviceInfo = [
302+
'rest' => [
303+
'resourcePath' => self::RESOURCE_PATH . '/' . $pageId,
304+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE,
305+
],
306+
'soap' => [
307+
'service' => self::SERVICE_NAME,
308+
'serviceVersion' => self::SERVICE_VERSION,
309+
'operation' => self::SERVICE_NAME . 'DeleteById',
310+
],
311+
];
312+
313+
$this->_webApiCall($serviceInfo, [PageInterface::PAGE_ID => $pageId]);
314+
}
252315
}

0 commit comments

Comments
 (0)