Skip to content

Commit c716dcf

Browse files
author
Serhii Bohomaz
committed
MC-39587: Create automated test for: "Add unexisting product to comparation list"
1 parent 9faf8e9 commit c716dcf

File tree

1 file changed

+8
-4
lines changed
  • dev/tests/integration/testsuite/Magento/Catalog/Controller/Product

1 file changed

+8
-4
lines changed

dev/tests/integration/testsuite/Magento/Catalog/Controller/Product/CompareTest.php

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ class CompareTest extends AbstractController
3636
/** @var Visitor */
3737
private $visitor;
3838

39+
/** @var Parameters */
40+
private $parameters;
41+
3942
/**
4043
* @inheritDoc
4144
*/
@@ -47,6 +50,7 @@ protected function setUp(): void
4750
$this->productRepository = $this->_objectManager->get(ProductRepository::class);
4851
$this->customerSession = $this->_objectManager->get(Session::class);
4952
$this->visitor = $this->_objectManager->get(Visitor::class);
53+
$this->parameters = $this->_objectManager->get(Parameters::class);
5054
}
5155

5256
/**
@@ -262,13 +266,14 @@ public function testRemoveActionProductNameXss(): void
262266
* @magentoDataFixture Magento/Customer/_files/customer.php
263267
* @return void
264268
*/
265-
public function testAddNotExistingProductToCompactionList() : void
269+
public function testAddNotExistingProductToCompareList(): void
266270
{
267271
$this->customerSession->loginById(1);
268272
$this->prepareReferer();
269273
$this->getRequest()->setMethod(HttpRequest::METHOD_POST);
270274
$this->getRequest()->setParams(['product' => 787586534]);
271275
$this->dispatch('catalog/product_compare/add/');
276+
$this->assertSessionMessages($this->isEmpty(), MessageInterface::TYPE_ERROR);
272277
$this->_assertCompareListEquals([]);
273278
$this->assertRedirect($this->stringContains('not_existing'));
274279
}
@@ -280,9 +285,8 @@ public function testAddNotExistingProductToCompactionList() : void
280285
*/
281286
private function prepareReferer(): void
282287
{
283-
$parameters = $this->_objectManager->create(Parameters::class);
284-
$parameters->set('HTTP_REFERER', 'http://localhost/not_existing');
285-
$this->getRequest()->setServer($parameters);
288+
$this->parameters->set('HTTP_REFERER', 'http://localhost/not_existing');
289+
$this->getRequest()->setServer($this->parameters);
286290
}
287291

288292
/**

0 commit comments

Comments
 (0)