Skip to content

Commit 7ea649e

Browse files
committed
MAGETWO-89670: Introduce Product Link type
- cover with integration tests
1 parent c9d7e3a commit 7ea649e

File tree

2 files changed

+86
-0
lines changed

2 files changed

+86
-0
lines changed
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Catalog\Controller\Adminhtml\Product;
10+
11+
/**
12+
* @magentoAppArea adminhtml
13+
*/
14+
class GetSelectedTest extends \Magento\TestFramework\TestCase\AbstractBackendController
15+
{
16+
/**
17+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
18+
*/
19+
public function testExecute() : void
20+
{
21+
$objectManager = \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
22+
$productRepository = $objectManager->get(\Magento\Catalog\Api\ProductRepositoryInterface::class);
23+
24+
$product = $productRepository->get('simple');
25+
$this->getRequest()
26+
->setPostValue('productId', $product->getId());
27+
$this->dispatch('backend/catalog/product/getSelected');
28+
$responseBody = $this->getResponse()->getBody();
29+
$this->assertContains(
30+
'{"value":"1","label":"Simple Product","is_active":1,"path":"simple"}',
31+
$responseBody
32+
);
33+
}
34+
35+
public function testExecuteNonExistingSearchKey() : void
36+
{
37+
$this->getRequest()
38+
->setPostValue('productId', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ');
39+
$this->dispatch('backend/catalog/product/getSelected');
40+
$responseBody = $this->getResponse()->getBody();
41+
$this->assertContains('[]', $responseBody);
42+
}
43+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
declare(strict_types=1);
8+
9+
namespace Magento\Catalog\Controller\Adminhtml\Product;
10+
11+
/**
12+
* @magentoAppArea adminhtml
13+
*/
14+
class SearchTest extends \Magento\TestFramework\TestCase\AbstractBackendController
15+
{
16+
/**
17+
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
18+
*/
19+
public function testExecute() : void
20+
{
21+
$this->getRequest()
22+
->setPostValue('searchKey', 'simple')
23+
->setPostValue('page', 1)
24+
->setPostValue('limit', 50);
25+
$this->dispatch('backend/catalog/product/search');
26+
$responseBody = $this->getResponse()->getBody();
27+
$this->assertContains(
28+
'"options":{"1":{"value":"1","label":"Simple Product","is_active":1,"path":"simple","optgroup":false}',
29+
$responseBody
30+
);
31+
}
32+
33+
public function testExecuteNonExistingSearchKey() : void
34+
{
35+
$this->getRequest()
36+
->setPostValue('searchKey', '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ')
37+
->setPostValue('page', 1)
38+
->setPostValue('limit', 50);
39+
$this->dispatch('backend/catalog/product/search');
40+
$responseBody = $this->getResponse()->getBody();
41+
$this->assertContains('{"options":[],"total":0}', $responseBody);
42+
}
43+
}

0 commit comments

Comments
 (0)