Skip to content

Commit c7d9900

Browse files
committed
MQE-1750: unit tests and some code refactor.
1 parent 7c3bd33 commit c7d9900

File tree

2 files changed

+22
-28
lines changed

2 files changed

+22
-28
lines changed

dev/tests/unit/Magento/FunctionalTestFramework/Composer/ComposerInstallTest.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,50 +16,46 @@ class ComposerInstallTest extends MagentoTestCase
1616
*
1717
* @var ComposerInstall
1818
*/
19-
private static $composer;
19+
private $composer;
2020

21-
public static function setUpBeforeClass()
21+
public function setUp()
2222
{
23-
parent::setUpBeforeClass();
24-
2523
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
2624
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';
2725

28-
self::$composer = new ComposerInstall($composerJson);
26+
$this->composer = new ComposerInstall($composerJson);
2927
}
3028

3129
/**
3230
* Test isMftfTestPackage()
3331
*/
3432
public function testIsMftfTestPackage()
3533
{
36-
$this->assertTrue(self::$composer->isMftfTestPackage('magento/module2-functional-test'));
34+
$this->assertTrue($this->composer->isMftfTestPackage('magento/module2-functional-test'));
3735
}
3836

3937
/**
4038
* Test isMagentoPackage()
4139
*/
4240
public function testIsMagentoPackage()
4341
{
44-
$this->assertTrue(self::$composer->isMagentoPackage('magento/module-authorization'));
42+
$this->assertTrue($this->composer->isMagentoPackage('magento/module-authorization'));
4543
}
4644

4745
/**
4846
* Test isInstalledPackageOfType()
4947
*/
5048
public function testIsInstalledPackageOfType()
5149
{
52-
$this->assertTrue(
53-
self::$composer->isInstalledPackageOfType('composer/composer', 'library')
54-
);
50+
$this->assertTrue($this->composer->isInstalledPackageOfType('composer/composer', 'library'));
5551
}
5652

5753
/**
5854
* Test getInstalledTestPackages()
5955
*/
6056
public function testGetInstalledTestPackages()
6157
{
62-
$output = self::$composer->getInstalledTestPackages();
58+
$output = $this->composer->getInstalledTestPackages();
6359
$this->assertCount(1, $output);
6460
$this->assertArrayHasKey('magento/module2-functional-test', $output);
6561
}

dev/tests/unit/Magento/FunctionalTestFramework/Composer/ComposerPackageTest.php

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,14 @@ class ComposerPackageTest extends MagentoTestCase
1717
*
1818
* @var ComposerPackage
1919
*/
20-
private static $composer;
20+
private $composer;
2121

22-
public static function setUpBeforeClass()
22+
public function setUp()
2323
{
24-
parent::setUpBeforeClass();
25-
2624
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
2725
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';
2826

29-
self::$composer = new ComposerPackage($composerJson);
27+
$this->composer = new ComposerPackage($composerJson);
3028
}
3129

3230
/**
@@ -35,7 +33,7 @@ public static function setUpBeforeClass()
3533
public function testGetName()
3634
{
3735
$expected = 'magento/module2-functional-test';
38-
$this->assertEquals($expected, self::$composer->getName());
36+
$this->assertEquals($expected, $this->composer->getName());
3937
}
4038

4139
/**
@@ -44,7 +42,7 @@ public function testGetName()
4442
public function testGetType()
4543
{
4644
$expected = 'magento2-functional-test-module';
47-
$this->assertEquals($expected, self::$composer->getType());
45+
$this->assertEquals($expected, $this->composer->getType());
4846
}
4947

5048
/**
@@ -53,7 +51,7 @@ public function testGetType()
5351
public function testGetVersion()
5452
{
5553
$expected = '1.0.0';
56-
$this->assertEquals($expected, self::$composer->getVersion());
54+
$this->assertEquals($expected, $this->composer->getVersion());
5755
}
5856

5957
/**
@@ -62,7 +60,7 @@ public function testGetVersion()
6260
public function testGetDescription()
6361
{
6462
$expected = 'MFTF tests for magento';
65-
$this->assertEquals($expected, self::$composer->getDescription());
63+
$this->assertEquals($expected, $this->composer->getDescription());
6664
}
6765

6866
/**
@@ -71,7 +69,7 @@ public function testGetDescription()
7169
public function testGetRequires()
7270
{
7371
$expected = 'magento/magento2-functional-testing-framework';
74-
$output = self::$composer->getRequires();
72+
$output = $this->composer->getRequires();
7573
$this->assertCount(1, $output);
7674
$this->assertArrayHasKey($expected, $output);
7775
}
@@ -82,7 +80,7 @@ public function testGetRequires()
8280
public function testGetDevRequires()
8381
{
8482
$expected = ['phpunit/phpunit'];
85-
$this->assertEquals($expected, array_keys(self::$composer->getDevRequires()));
83+
$this->assertEquals($expected, array_keys($this->composer->getDevRequires()));
8684
}
8785

8886
/**
@@ -99,7 +97,7 @@ public function testGetSuggests()
9997
'magento/module-three',
10098
'magento/module-four'
10199
];
102-
$this->assertEquals($expected, array_keys(self::$composer->getSuggests()));
100+
$this->assertEquals($expected, array_keys($this->composer->getSuggests()));
103101
}
104102

105103
/**
@@ -112,15 +110,15 @@ public function testGetSuggestedMagentoModules()
112110
'Magento_ModuleY',
113111
'Magento_ModuleZ'
114112
];
115-
$this->assertEquals($expected, self::$composer->getSuggestedMagentoModules());
113+
$this->assertEquals($expected, $this->composer->getSuggestedMagentoModules());
116114
}
117115

118116
/**
119117
* Test isMftfTestPackage()
120118
*/
121119
public function testIsMftfTestPackage()
122120
{
123-
$this->assertTrue(self::$composer->isMftfTestPackage());
121+
$this->assertTrue($this->composer->isMftfTestPackage());
124122
}
125123

126124
/**
@@ -145,7 +143,7 @@ public function testGetRequiresForPackage()
145143
];
146144
$this->assertEquals(
147145
$expected,
148-
array_keys(self::$composer->getRequiresForPackage('magento/magento2-functional-testing-framework', '2.5.0'))
146+
array_keys($this->composer->getRequiresForPackage('magento/magento2-functional-testing-framework', '2.5.0'))
149147
);
150148
}
151149

@@ -155,7 +153,7 @@ public function testGetRequiresForPackage()
155153
public function testIsPackageRequiredInComposerJson()
156154
{
157155
$this->assertTrue(
158-
self::$composer->isPackageRequiredInComposerJson('magento/magento2-functional-testing-framework')
156+
$this->composer->isPackageRequiredInComposerJson('magento/magento2-functional-testing-framework')
159157
);
160158
}
161159

@@ -166,7 +164,7 @@ public function testGetRootPackage()
166164
{
167165
$this->assertInstanceOf(
168166
RootPackage::class,
169-
self::$composer->getRootPackage()
167+
$this->composer->getRootPackage()
170168
);
171169
}
172170
}

0 commit comments

Comments
 (0)