From a90893cee8e2217354139cb5ef7c2c0e3f3afa46 Mon Sep 17 00:00:00 2001 From: Sergii Kovalenko <skovalenko@magento.com> Date: Wed, 21 Dec 2016 17:43:03 +0200 Subject: [PATCH] MAGETWO-61829: SOAP/REST tests fail on develop branch but builds are green --- .../Api/ProductCustomOptionRepositoryTest.php | 12 ++----- .../Api/ProductRepositoryInterfaceTest.php | 20 +---------- .../_files/product_with_two_websites.php | 20 +++++------ .../product_with_two_websites_rollback.php | 35 +++++++++++++++++++ .../Magento/Catalog/_files/second_website.php | 2 ++ .../_files/second_website_rollback.php | 22 ++++++++++++ 6 files changed, 71 insertions(+), 40 deletions(-) create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites_rollback.php create mode 100644 dev/tests/integration/testsuite/Magento/Catalog/_files/second_website_rollback.php diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php index 0b761d8c191..6a09bea591c 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductCustomOptionRepositoryTest.php @@ -391,6 +391,7 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract */ public function testUpdateNegative($optionData, $message) { + $this->_markTestAsRestOnly(); $productSku = 'simple'; /** @var ProductRepository $productRepository */ $productRepository = $this->objectManager->create(ProductRepository::class); @@ -403,18 +404,9 @@ class ProductCustomOptionRepositoryTest extends WebapiAbstract 'resourcePath' => '/V1/products/options/' . $optionId, 'httpMethod' => \Magento\Framework\Webapi\Rest\Request::HTTP_METHOD_PUT, ], - 'soap' => [ - 'service' => self::SERVICE_NAME, - 'serviceVersion' => 'V1', - 'operation' => self::SERVICE_NAME . 'Save', - ], ]; - if (TESTS_WEB_API_ADAPTER == self::ADAPTER_SOAP) { - $this->setExpectedException('SoapFault'); - } else { - $this->setExpectedException('Exception', $message, 400); - } + $this->setExpectedException('Exception', $message, 400); $this->_webApiCall($serviceInfo, ['option' => $optionData]); } diff --git a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php index cd02c6d4d75..ed641ac0f85 100644 --- a/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php +++ b/dev/tests/api-functional/testsuite/Magento/Catalog/Api/ProductRepositoryInterfaceTest.php @@ -134,15 +134,6 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract ]; } - private function markAreaAsSecure() - { - /** @var \Magento\Framework\Registry $registry */ - $registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() - ->get(\Magento\Framework\Registry::class); - $registry->unregister("isSecureArea"); - $registry->register("isSecureArea", true); - } - /** * Test removing association between product and website 1 * @magentoApiDataFixture Magento/Catalog/_files/product_with_two_websites.php @@ -169,9 +160,6 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]["website_ids"], $websitesData["website_ids"] ); - $this->deleteProduct($productBuilder[ProductInterface::SKU]); - $this->markAreaAsSecure(); - $website->delete(); } /** @@ -198,9 +186,6 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]["website_ids"], $websitesData["website_ids"] ); - $this->deleteProduct($productBuilder[ProductInterface::SKU]); - $this->markAreaAsSecure(); - $website->delete(); } /** @@ -222,7 +207,7 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract $websitesData = [ 'website_ids' => [ 1, - $website->getId(), + (int) $website->getId(), ] ]; $productBuilder[ProductInterface::EXTENSION_ATTRIBUTES_KEY] = $websitesData; @@ -231,9 +216,6 @@ class ProductRepositoryInterfaceTest extends WebapiAbstract $response[ProductInterface::EXTENSION_ATTRIBUTES_KEY]["website_ids"], $websitesData["website_ids"] ); - $this->deleteProduct($productBuilder[ProductInterface::SKU]); - $this->markAreaAsSecure(); - $website->delete(); } /** diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites.php index fa64de38e43..426ee922f26 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites.php @@ -9,25 +9,23 @@ use Magento\Catalog\Api\Data\ProductInterface; $objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); /** @var Magento\Store\Model\Website $website */ $website = $objectManager->get(Magento\Store\Model\Website::class); -$website->load('second_website', 'code'); -if (!$website->getId()) { - $website->setData( - [ - 'code' => 'second_website', - 'name' => 'Test Website', - ] - ); +$website->setData( + [ + 'code' => 'second_website', + 'name' => 'Test Website', + ] +); - $website->save(); -} +$website->save(); + +$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); /** @var $product \Magento\Catalog\Model\Product */ $product = \Magento\TestFramework\Helper\Bootstrap::getObjectManager() ->create(ProductInterface::class); $product ->setTypeId('simple') - ->setId(1) ->setAttributeSetId(4) ->setWebsiteIds([1, $website->getId()]) ->setName('Simple Product') diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites_rollback.php new file mode 100644 index 00000000000..68f1106dcfe --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/product_with_two_websites_rollback.php @@ -0,0 +1,35 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +use Magento\Catalog\Api\Data\ProductInterface; + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); + +/** @var \Magento\Framework\Registry $registry */ +$registry = $objectManager + ->get(\Magento\Framework\Registry::class); +$registry->unregister("isSecureArea"); +$registry->register("isSecureArea", true); + +/** @var Magento\Store\Model\Website $website */ +$website = $objectManager->create(\Magento\Store\Model\Website::class); +$website->load('second_website'); +$website->delete(); + +/** @var \Magento\Catalog\Api\ProductRepositoryInterface $productRepository */ +$productRepository = $objectManager->create(\Magento\Catalog\Api\ProductRepositoryInterface::class); + +try { + $firstProduct = $productRepository->get('unique-simple-azaza'); + $firstProduct->delete(); +} catch (\Magento\Framework\Exception\NoSuchEntityException $exception) { + //Product already removed +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website.php index 6749d421e79..4dc026d6fad 100644 --- a/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website.php +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website.php @@ -19,3 +19,5 @@ if (!$website->getId()) { $website->save(); } + +$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); diff --git a/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website_rollback.php b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website_rollback.php new file mode 100644 index 00000000000..173793a1caa --- /dev/null +++ b/dev/tests/integration/testsuite/Magento/Catalog/_files/second_website_rollback.php @@ -0,0 +1,22 @@ +<?php +/** + * Copyright © 2016 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +$registry = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->get('Magento\Framework\Registry'); +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', true); + +$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager(); +$website = $objectManager->get(Magento\Store\Model\Website::class); +$website->load('test_website', 'code'); + +if ($website->getId()) { + $website->delete(); +} + +$registry->unregister('isSecureArea'); +$registry->register('isSecureArea', false); + +$objectManager->get(\Magento\Store\Model\StoreManagerInterface::class)->reinitStores(); -- GitLab