Skip to content

Commit de444c6

Browse files
committed
AC-15000: [CE] PHPUnit cut 12: related tests
1 parent 81e6839 commit de444c6

File tree

14 files changed

+28
-90
lines changed

14 files changed

+28
-90
lines changed

app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/InfoTest.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,4 @@ public function testIsHidden(): void
7373
$this->assertFalse($this->infoBlock->isHidden());
7474
}
7575

76-
protected function tearDown(): void
77-
{
78-
// Reset ObjectManager instance using reflection to avoid type issues
79-
$reflection = new \ReflectionClass(AppObjectManager::class);
80-
$property = $reflection->getProperty('_instance');
81-
$property->setAccessible(true);
82-
$property->setValue(null, null); // For static properties: setValue(object, value)
83-
}
8476
}

app/code/Magento/Integration/Test/Unit/Block/Adminhtml/Integration/Edit/Tab/WebapiTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,4 @@ private function getWebapiBlock(?array $integrationData = [], array $selectedRes
284284
]
285285
);
286286
}
287-
288-
protected function tearDown(): void
289-
{
290-
// Reset ObjectManager instance using reflection to avoid type issues
291-
$reflection = new \ReflectionClass(AppObjectManager::class);
292-
$property = $reflection->getProperty('_instance');
293-
$property->setAccessible(true);
294-
$property->setValue(null, null); // For static properties: setValue(object, value)
295-
}
296287
}

app/code/Magento/Integration/Test/Unit/Controller/Adminhtml/IntegrationTestCase.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Magento\Framework\View\Page\Config;
3131
use Magento\Framework\View\Page\Title;
3232
use Magento\Framework\View\Result\Page;
33+
use Magento\Framework\View\Layout as LayoutModel;
3334
use Magento\Integration\Api\IntegrationServiceInterface;
3435
use Magento\Integration\Api\OauthServiceInterface;
3536
use Magento\Integration\Block\Adminhtml\Integration\Edit\Tab\Info;
@@ -245,7 +246,7 @@ protected function _createIntegrationController($actionName)
245246
->getMock();
246247
// Use concrete Layout class since we need getNode() method which isn't in interface
247248
$this->_layoutMock = $this->createPartialMockWithReflection(
248-
\Magento\Framework\View\Layout::class,
249+
LayoutModel::class,
249250
['getUpdate', 'getNode', 'getMessagesBlock', 'getBlock']
250251
);
251252
$this->_layoutMergeMock = $this->getMockBuilder(
@@ -405,12 +406,12 @@ protected function _getSampleIntegrationData()
405406
/**
406407
* Return integration model mock with sample data.
407408
*
408-
* @return \Magento\Integration\Model\Integration|MockObject
409+
* @return IntegrationModel|MockObject
409410
*/
410411
protected function _getIntegrationModelMock()
411412
{
412413
$integrationModelMock = $this->createPartialMockWithReflection(
413-
\Magento\Integration\Model\Integration::class,
414+
IntegrationModel::class,
414415
['setStatus', 'save', '__wakeup', 'getData']
415416
);
416417

app/code/Magento/Integration/Test/Unit/Model/Oauth/ConsumerTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Magento\Framework\Stdlib\DateTime\DateTime;
1818
use Magento\Framework\Url\Validator as UrlValidator;
1919
use Magento\Integration\Helper\Oauth\Data;
20+
use Magento\Integration\Model\ResourceModel\Oauth\Consumer as ConsumerResourceModel;
2021
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
2122
use Magento\Integration\Model\Oauth\Consumer;
2223
use Magento\Integration\Model\Oauth\Consumer\Validator\KeyLength;
@@ -108,7 +109,7 @@ protected function setUp(): void
108109
->willReturn(Data::CONSUMER_EXPIRATION_PERIOD_DEFAULT);
109110

110111
$this->resourceMock = $this->createPartialMockWithReflection(
111-
\Magento\Integration\Model\ResourceModel\Oauth\Consumer::class,
112+
ConsumerResourceModel::class,
112113
['selectByCompositeKey', 'deleteOldEntries', 'getIdFieldName']
113114
);
114115
$this->resourceCollectionMock = $this->createMock(AbstractDb::class);

app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/ConsumerTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,15 +72,6 @@ protected function setUp(): void
7272
);
7373
}
7474

75-
protected function tearDown(): void
76-
{
77-
// Reset ObjectManager instance
78-
$reflection = new \ReflectionClass(AppObjectManager::class);
79-
$property = $reflection->getProperty('_instance');
80-
$property->setAccessible(true);
81-
$property->setValue(null, null);
82-
}
83-
8475
public function testAfterDelete(): void
8576
{
8677
$this->connectionMock->expects($this->exactly(2))->method('delete');

app/code/Magento/Integration/Test/Unit/Model/ResourceModel/Oauth/TokenTest.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Magento\Framework\ObjectManagerInterface;
1717
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager;
1818
use Magento\Integration\Model\ResourceModel\Oauth\Token;
19+
use Magento\Integration\Model\Oauth\Token as TokenModel;
1920
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
2021
use PHPUnit\Framework\MockObject\MockObject;
2122
use PHPUnit\Framework\TestCase;
@@ -63,19 +64,10 @@ protected function setUp(): void
6364
);
6465
}
6566

66-
protected function tearDown(): void
67-
{
68-
// Reset ObjectManager instance
69-
$reflection = new \ReflectionClass(AppObjectManager::class);
70-
$property = $reflection->getProperty('_instance');
71-
$property->setAccessible(true);
72-
$property->setValue(null, null);
73-
}
74-
7567
public function testCleanOldAuthorizedTokensExcept(): void
7668
{
7769
$tokenMock = $this->createPartialMockWithReflection(
78-
\Magento\Integration\Model\Oauth\Token::class,
70+
TokenModel::class,
7971
['getAuthorized', 'getConsumerId', 'getCustomerId', 'getAdminId', 'getId']
8072
);
8173
$tokenMock->expects($this->any())->method('getId')->willReturn(1);

app/code/Magento/Msrp/Test/Unit/Ui/DataProvider/Product/Listing/Collector/MsrpPriceTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
use Magento\Framework\Pricing\PriceCurrencyInterface;
1818
use Magento\Framework\TestFramework\Unit\Helper\MockCreationTrait;
1919
use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper;
20+
use Magento\Framework\Pricing\PriceInfo\Base as BasePriceInfo;
2021
use Magento\Msrp\Api\Data\ProductRender\MsrpPriceInfoInterface;
2122
use Magento\Msrp\Api\Data\ProductRender\MsrpPriceInfoInterfaceFactory;
2223
use Magento\Msrp\Helper\Data;
2324
use Magento\Msrp\Model\Config;
2425
use Magento\Msrp\Ui\DataProvider\Product\Listing\Collector\MsrpPrice;
26+
use Magento\Msrp\Pricing\Price\MsrpPrice as MsrpPriceModel;
2527
use PHPUnit\Framework\MockObject\MockObject;
2628
use PHPUnit\Framework\TestCase;
2729

@@ -163,13 +165,13 @@ public function testCollect(): void
163165
$this->priceInfoExtensionFactory->expects($this->once())
164166
->method('create')
165167
->willReturn($extensionAttributes);
166-
$price = $this->getMockBuilder(\Magento\Msrp\Pricing\Price\MsrpPrice::class)
168+
$price = $this->getMockBuilder(MsrpPriceModel::class)
167169
->disableOriginalConstructor()
168170
->getMock();
169171

170172
// Product's PriceInfo needs getPrice method
171173
$priceInfo = $this->createPartialMockWithReflection(
172-
\Magento\Framework\Pricing\PriceInfo\Base::class,
174+
BasePriceInfo::class,
173175
['getPrice']
174176
);
175177
$priceInfo->expects($this->once())

app/code/Magento/Tax/Test/Unit/Block/Adminhtml/Items/Price/RendererTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,6 @@ protected function setUp(): void
6969
);
7070
}
7171

72-
protected function tearDown(): void
73-
{
74-
// Reset ObjectManager instance
75-
$reflection = new \ReflectionClass(AppObjectManager::class);
76-
$instanceProperty = $reflection->getProperty('_instance');
77-
$instanceProperty->setAccessible(true);
78-
$instanceProperty->setValue(null, null);
79-
}
80-
8172
public function testDisplayPriceInclTax(): void
8273
{
8374
$flag = false;

app/code/Magento/Tax/Test/Unit/Block/Adminhtml/Rule/Edit/FormTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,15 +133,6 @@ protected function setUp(): void
133133
]);
134134
}
135135

136-
protected function tearDown(): void
137-
{
138-
// Reset ObjectManager instance
139-
$reflection = new \ReflectionClass(AppObjectManager::class);
140-
$instanceProperty = $reflection->getProperty('_instance');
141-
$instanceProperty->setAccessible(true);
142-
$instanceProperty->setValue(null, null);
143-
}
144-
145136
/**
146137
* Check tax lazy loading URL.
147138
*

app/code/Magento/Tax/Test/Unit/Block/Checkout/ShippingTest.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,6 @@ protected function setUp(): void
4747
);
4848
}
4949

50-
protected function tearDown(): void
51-
{
52-
// Reset ObjectManager instance
53-
$reflection = new \ReflectionClass(AppObjectManager::class);
54-
$instanceProperty = $reflection->getProperty('_instance');
55-
$instanceProperty->setAccessible(true);
56-
$instanceProperty->setValue(null, null);
57-
}
58-
5950
/**
6051
* @param string|null $shippingMethod
6152
* @param bool $expectedResult

0 commit comments

Comments
 (0)