Skip to content

Commit 63c5459

Browse files
committed
Fix for missing context reset of ComponentRegistrar
This test tries to setup a test environment with two modules and one theme to test the generator. During the test run, the test environment and the complete module stack is processed by the generator. So the test takes on my machine 25 seconds with xdebug enabled. After resetting the registrar the complete test runs in ~50ms with xdebug enabled. Without the reset ~12.000 files are scanned. With the reset only 5 files are scanned. This test is not a unit test. It is an integration test.
1 parent fbe667e commit 63c5459

File tree

2 files changed

+11
-5
lines changed
  • app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier
  • dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Dictionary

2 files changed

+11
-5
lines changed

app/code/Magento/Catalog/Test/Unit/Ui/DataProvider/Product/Form/Modifier/EavTest.php

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,10 @@ public function testSetupAttributeMetaDefaultAttribute($productId, $productRequi
490490
->method('getNote')
491491
->willReturn($note);
492492

493+
$this->productAttributeMock->expects($this->any())
494+
->method('getDefaultFrontendLabel')
495+
->willReturn(new Phrase('mylabel'));
496+
493497
$attributeMock = $this->getMockBuilder(AttributeInterface::class)
494498
->setMethods(['getValue'])
495499
->disableOriginalConstructor()
@@ -561,7 +565,7 @@ private function defaultNullProdNotNewAndRequired()
561565
'required' => true,
562566
'notice' => null,
563567
'default' => null,
564-
'label' => new Phrase(''),
568+
'label' => new Phrase('mylabel'),
565569
'code' => 'code',
566570
'source' => 'product-details',
567571
'scopeLabel' => '',
@@ -588,7 +592,7 @@ private function defaultNullProdNotNewAndNotRequired()
588592
'required' => false,
589593
'notice' => null,
590594
'default' => null,
591-
'label' => new Phrase(''),
595+
'label' => new Phrase('mylabel'),
592596
'code' => 'code',
593597
'source' => 'product-details',
594598
'scopeLabel' => '',
@@ -615,7 +619,7 @@ private function defaultNullProdNewAndNotRequired()
615619
'required' => false,
616620
'notice' => null,
617621
'default' => 'required_value',
618-
'label' => new Phrase(''),
622+
'label' => new Phrase('mylabel'),
619623
'code' => 'code',
620624
'source' => 'product-details',
621625
'scopeLabel' => '',
@@ -642,7 +646,7 @@ private function defaultNullProdNewAndRequired()
642646
'required' => false,
643647
'notice' => null,
644648
'default' => 'required_value',
645-
'label' => new Phrase(''),
649+
'label' => new Phrase('mylabel'),
646650
'code' => 'code',
647651
'source' => 'product-details',
648652
'scopeLabel' => '',
@@ -669,7 +673,7 @@ private function defaultNullProdNewAndRequiredAndFilledNotice()
669673
'required' => false,
670674
'notice' => __('example notice'),
671675
'default' => 'required_value',
672-
'label' => new Phrase(''),
676+
'label' => new Phrase('mylabel'),
673677
'code' => 'code',
674678
'source' => 'product-details',
675679
'scopeLabel' => '',

dev/tests/integration/testsuite/Magento/Setup/Module/I18n/Dictionary/GeneratorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
namespace Magento\Setup\Module\I18n\Dictionary;
77

88
use Magento\Framework\Component\ComponentRegistrar;
9+
use Magento\Setup\Module\I18n\Dictionary\Generator;
910
use Magento\Setup\Module\I18n\ServiceLocator;
1011

1112
class GeneratorTest extends \PHPUnit\Framework\TestCase
@@ -46,6 +47,7 @@ protected function setUp()
4647
$paths = $reflection->getProperty('paths');
4748
$paths->setAccessible(true);
4849
$this->backupRegistrar = $paths->getValue();
50+
$paths->setValue(['module' => [], 'theme' => []]);
4951
$paths->setAccessible(false);
5052

5153
$this->testDir = realpath(__DIR__ . '/_files');

0 commit comments

Comments
 (0)