Skip to content

Commit 1f48e45

Browse files
author
Willem Wigman
committed
#4 Code improvements
1 parent 40ec1d5 commit 1f48e45

File tree

2 files changed

+10
-23
lines changed

2 files changed

+10
-23
lines changed

tests/Integration/AbstractFrontendControllerTest.php

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55

66
use IntegerNet\GlobalCustomLayout\Test\Util\CategoryLayoutUpdateManager;
77
use Magento\Catalog\Model\Category\Attribute\LayoutUpdateManager;
8-
use Magento\Catalog\Model\Session;
98
use Magento\Framework\ObjectManagerInterface;
10-
use Magento\Framework\Registry;
119
use Magento\Framework\View\LayoutInterface;
1210
use Magento\TestFramework\Helper\Bootstrap;
1311
use Magento\TestFramework\TestCase\AbstractController;
@@ -21,37 +19,24 @@ abstract class AbstractFrontendControllerTest extends AbstractController
2119
/**
2220
* @var ObjectManagerInterface
2321
*/
24-
private $objectManager;
25-
26-
/**
27-
* @var Registry
28-
*/
29-
private $registry;
30-
31-
/**
32-
* @var Session
33-
*/
34-
private $session;
22+
protected $objectManager;
3523

3624
/**
3725
* @var LayoutInterface
3826
*/
39-
private $layout;
27+
protected $layoutInterface;
4028

4129
/**
4230
* @inheritdoc
4331
*/
4432
protected function setUp()
4533
{
4634
$this->objectManager = Bootstrap::getObjectManager();
35+
$this->layoutInterface = $this->objectManager->get(LayoutInterface::class);
4736

4837
$this->setUpPreferences();
4938

5039
parent::setUp();
51-
52-
$this->registry = $this->objectManager->get(Registry::class);
53-
$this->layout = $this->objectManager->get(LayoutInterface::class);
54-
$this->session = $this->objectManager->get(Session::class);
5540
}
5641

5742
private function setUpPreferences(): void

tests/Integration/CategoryFrontendControllerTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
use IntegerNet\GlobalCustomLayout\Test\Util\CategoryLayoutUpdateManager;
77
use Magento\Catalog\Api\CategoryRepositoryInterface;
8+
use Magento\Framework\Exception\CouldNotSaveException;
9+
use Magento\Framework\Exception\NoSuchEntityException;
810
use Magento\TestFramework\Helper\Bootstrap;
911

1012
/**
@@ -17,8 +19,8 @@ class CategoryFrontendControllerTest extends AbstractFrontendControllerTest
1719
* Check that Global Custom Layout Update files work for Category views.
1820
*
1921
* @return void
20-
* @throws \Magento\Framework\Exception\CouldNotSaveException
21-
* @throws \Magento\Framework\Exception\NoSuchEntityException
22+
* @throws CouldNotSaveException
23+
* @throws NoSuchEntityException
2224
*
2325
* @magentoDataFixture Magento/CatalogUrlRewrite/_files/categories_with_product_ids.php
2426
*/
@@ -29,11 +31,11 @@ public function testViewWithGlobalCustomUpdate(): void
2931
$categoryId = 5;
3032

3133
/** @var CategoryLayoutUpdateManager $layoutManager */
32-
$layoutManager = Bootstrap::getObjectManager()->get(CategoryLayoutUpdateManager::class);
34+
$layoutManager = $this->objectManager->get(CategoryLayoutUpdateManager::class);
3335
$layoutManager->setCategoryFakeFiles(0, [$file]);
3436

3537
/** @var CategoryRepositoryInterface $categoryRepo */
36-
$categoryRepo = Bootstrap::getObjectManager()->create(CategoryRepositoryInterface::class);
38+
$categoryRepo = $this->objectManager->create(CategoryRepositoryInterface::class);
3739
$category = $categoryRepo->get($categoryId);
3840

3941
//Updating the custom attribute.
@@ -44,7 +46,7 @@ public function testViewWithGlobalCustomUpdate(): void
4446
$this->dispatch("catalog/category/view/id/$categoryId");
4547

4648
//Layout handles must contain the file.
47-
$handles = Bootstrap::getObjectManager()->get(\Magento\Framework\View\LayoutInterface::class)
49+
$handles = $this->layoutInterface
4850
->getUpdate()
4951
->getHandles();
5052
$this->assertContains("catalog_category_view_selectable_0_{$file}", $handles);

0 commit comments

Comments
 (0)