Skip to content

Commit 9891e5d

Browse files
committed
MQE-1750: unit tests
1 parent 83c3fbd commit 9891e5d

File tree

13 files changed

+1055
-58
lines changed

13 files changed

+1055
-58
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
8+
9+
use Magento\FunctionalTestingFramework\Composer\ComposerInstall;
10+
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
11+
12+
class ComposerInstallTest extends MagentoTestCase
13+
{
14+
/**
15+
* ComposerInstall instance to be tested
16+
*
17+
* @var ComposerInstall
18+
*/
19+
private static $composer;
20+
21+
public static function setUpBeforeClass()
22+
{
23+
parent::setUpBeforeClass();
24+
25+
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
26+
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';
27+
28+
self::$composer = new ComposerInstall($composerJson);
29+
}
30+
31+
/**
32+
* Test isMftfTestPackage()
33+
*/
34+
public function testIsMftfTestPackage()
35+
{
36+
$this->assertTrue(self::$composer->isMftfTestPackage('magento/module2-functional-test'));
37+
}
38+
39+
/**
40+
* Test isMagentoPackage()
41+
*/
42+
public function testIsMagentoPackage()
43+
{
44+
$this->assertTrue(self::$composer->isMagentoPackage('magento/module-authorization'));
45+
}
46+
47+
/**
48+
* Test isInstalledPackageOfType()
49+
*/
50+
public function testIsInstalledPackageOfType()
51+
{
52+
$this->assertTrue(
53+
self::$composer->isInstalledPackageOfType('composer/composer', 'library')
54+
);
55+
}
56+
57+
/**
58+
* Test getInstalledTestPackages()
59+
*/
60+
public function testGetInstalledTestPackages()
61+
{
62+
$output = self::$composer->getInstalledTestPackages();
63+
$this->assertCount(1, $output);
64+
$this->assertArrayHasKey('magento/module2-functional-test', $output);
65+
}
66+
}
Lines changed: 172 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,172 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
7+
namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;
8+
9+
use Magento\FunctionalTestingFramework\Composer\ComposerPackage;
10+
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
11+
use Composer\Package\RootPackage;
12+
13+
class ComposerPackageTest extends MagentoTestCase
14+
{
15+
/**
16+
* ComposerPackage instance to be tested
17+
*
18+
* @var ComposerPackage
19+
*/
20+
private static $composer;
21+
22+
public static function setUpBeforeClass()
23+
{
24+
parent::setUpBeforeClass();
25+
26+
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
27+
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';
28+
29+
self::$composer = new ComposerPackage($composerJson);
30+
}
31+
32+
/**
33+
* Test getName()
34+
*/
35+
public function testGetName()
36+
{
37+
$expected = 'magento/module2-functional-test';
38+
$this->assertEquals($expected, self::$composer->getName());
39+
}
40+
41+
/**
42+
* Test getType()
43+
*/
44+
public function testGetType()
45+
{
46+
$expected = 'magento2-functional-test-module';
47+
$this->assertEquals($expected, self::$composer->getType());
48+
}
49+
50+
/**
51+
* Test getVersion()
52+
*/
53+
public function testGetVersion()
54+
{
55+
$expected = '1.0.0';
56+
$this->assertEquals($expected, self::$composer->getVersion());
57+
}
58+
59+
/**
60+
* Test getDescription()
61+
*/
62+
public function testGetDescription()
63+
{
64+
$expected = 'MFTF tests for magento';
65+
$this->assertEquals($expected, self::$composer->getDescription());
66+
}
67+
68+
/**
69+
* Test getRequires()
70+
*/
71+
public function testGetRequires()
72+
{
73+
$expected = 'magento/magento2-functional-testing-framework';
74+
$output = self::$composer->getRequires();
75+
$this->assertCount(1, $output);
76+
$this->assertArrayHasKey($expected, $output);
77+
}
78+
79+
/**
80+
* Test getDevRequires()
81+
*/
82+
public function testGetDevRequires()
83+
{
84+
$expected = ['phpunit/phpunit'];
85+
$this->assertEquals($expected, array_keys(self::$composer->getDevRequires()));
86+
}
87+
88+
/**
89+
* Test getSuggests()
90+
*/
91+
public function testGetSuggests()
92+
{
93+
$expected = [
94+
'magento/module-one',
95+
'magento/module-module-x',
96+
'magento/module-two',
97+
'magento/module-module-y',
98+
'magento/module-module-z',
99+
'magento/module-three',
100+
'magento/module-four'
101+
];
102+
$this->assertEquals($expected, array_keys(self::$composer->getSuggests()));
103+
}
104+
105+
/**
106+
* Test getSuggestedMagentoModules()
107+
*/
108+
public function testGetSuggestedMagentoModules()
109+
{
110+
$expected = [
111+
'Magento_ModuleX',
112+
'Magento_ModuleY',
113+
'Magento_ModuleZ'
114+
];
115+
$this->assertEquals($expected, self::$composer->getSuggestedMagentoModules());
116+
}
117+
118+
/**
119+
* Test isMftfTestPackage()
120+
*/
121+
public function testIsMftfTestPackage()
122+
{
123+
$this->assertTrue(self::$composer->isMftfTestPackage());
124+
}
125+
126+
/**
127+
* Test getRequiresForPackage()
128+
*/
129+
public function testGetRequiresForPackage()
130+
{
131+
$expected = [
132+
'php',
133+
'ext-curl',
134+
'allure-framework/allure-codeception',
135+
'codeception/codeception',
136+
'consolidation/robo',
137+
'csharpru/vault-php',
138+
'csharpru/vault-php-guzzle6-transport',
139+
'flow/jsonpath',
140+
'fzaninotto/faker',
141+
'monolog/monolog',
142+
'mustache/mustache',
143+
'symfony/process',
144+
'vlucas/phpdotenv'
145+
];
146+
$this->assertEquals(
147+
$expected,
148+
array_keys(self::$composer->getRequiresForPackage('magento/magento2-functional-testing-framework', '2.5.0'))
149+
);
150+
}
151+
152+
/**
153+
* Test isPackageRequiredInComposerJson()
154+
*/
155+
public function testIsPackageRequiredInComposerJson()
156+
{
157+
$this->assertTrue(
158+
self::$composer->isPackageRequiredInComposerJson('magento/magento2-functional-testing-framework')
159+
);
160+
}
161+
162+
/**
163+
* Test getRootPackage()
164+
*/
165+
public function testGetRootPackage()
166+
{
167+
$this->assertInstanceOf(
168+
RootPackage::class,
169+
self::$composer->getRootPackage()
170+
);
171+
}
172+
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "magento/module2-functional-test",
3+
"type": "magento2-functional-test-module",
4+
"description": "MFTF tests for magento",
5+
"version": "1.0.0",
6+
"require": {
7+
"magento/magento2-functional-testing-framework": "^2.5.0"
8+
},
9+
"require-dev": {
10+
"phpunit/phpunit": "~6.5.0 || ~7.0.0"
11+
},
12+
"suggest": {
13+
"magento/module-one": "name: Magento_ModuleY, version: ~100.0.0",
14+
"magento/module-module-x": " type: magento2-module ,name: Magento_ModuleX, version: ~100.0.0",
15+
"magento/module-two": "*",
16+
"magento/module-module-y": "type: magento2-module, name:Magento_ModuleY,version:~100.0.0",
17+
"magento/module-module-z": " type:magento2-module, name: Magento_ModuleZ , version: ~100.0.0",
18+
"magento/module-three": "type: magento2-module, ~100.0.0",
19+
"magento/module-four": "some suggestions"
20+
}
21+
}

0 commit comments

Comments
 (0)