Skip to content

Commit 4398ea8

Browse files
MAGETWO-71659: Fix for url_rewrite on page delete via api #10568
2 parents d19e900 + 022febb commit 4398ea8

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,18 @@ public function testSearch()
284284
);
285285
}
286286

287+
/**
288+
* Create page with the same identifier after one was removed.
289+
*/
290+
public function testCreateSamePage()
291+
{
292+
$pageIdentifier = 'page-' . uniqid();
293+
294+
$pageId = $this->createPageWithIdentifier($pageIdentifier);
295+
$this->deletePageByIdentifier($pageId);
296+
$this->createPageWithIdentifier($pageIdentifier);
297+
}
298+
287299
/**
288300
* @return PageInterface[]
289301
*/
@@ -316,4 +328,55 @@ private function prepareCmsPages()
316328

317329
return $result;
318330
}
331+
332+
/**
333+
* Create page with hard-coded identifier to test with create-delete-create flow.
334+
* @param string $identifier
335+
* @return string
336+
*/
337+
private function createPageWithIdentifier($identifier)
338+
{
339+
$serviceInfo = [
340+
'rest' => [
341+
'resourcePath' => self::RESOURCE_PATH,
342+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_POST,
343+
],
344+
'soap' => [
345+
'service' => self::SERVICE_NAME,
346+
'serviceVersion' => self::SERVICE_VERSION,
347+
'operation' => self::SERVICE_NAME . 'Save',
348+
],
349+
];
350+
$requestData = ['page' =>
351+
[
352+
PageInterface::IDENTIFIER => $identifier,
353+
PageInterface::TITLE => 'Page title',
354+
],
355+
];
356+
357+
$result = $this->_webApiCall($serviceInfo, $requestData);
358+
return $result['id'];
359+
}
360+
361+
/**
362+
* Remove page with hard-coded-identifier
363+
* @param string $pageId
364+
* @return void
365+
*/
366+
private function deletePageByIdentifier($pageId)
367+
{
368+
$serviceInfo = [
369+
'rest' => [
370+
'resourcePath' => self::RESOURCE_PATH . '/' . $pageId,
371+
'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_DELETE,
372+
],
373+
'soap' => [
374+
'service' => self::SERVICE_NAME,
375+
'serviceVersion' => self::SERVICE_VERSION,
376+
'operation' => self::SERVICE_NAME . 'DeleteById',
377+
],
378+
];
379+
380+
$this->_webApiCall($serviceInfo, [PageInterface::PAGE_ID => $pageId]);
381+
}
319382
}

0 commit comments

Comments
 (0)