Skip to content

MQE-1750: unit tests #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Oct 9, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;

use Magento\FunctionalTestingFramework\Composer\ComposerInstall;
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;

class ComposerInstallTest extends MagentoTestCase
{
/**
* ComposerInstall instance to be tested
*
* @var ComposerInstall
*/
private $composer;

public function setUp()
{
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';

$this->composer = new ComposerInstall($composerJson);
}

/**
* Test isMftfTestPackage()
*/
public function testIsMftfTestPackage()
{
$this->assertTrue($this->composer->isMftfTestPackage('magento/module2-functional-test'));
}

/**
* Test isMagentoPackage()
*/
public function testIsMagentoPackage()
{
$this->assertTrue($this->composer->isMagentoPackage('magento/module-authorization'));
}

/**
* Test isInstalledPackageOfType()
*/
public function testIsInstalledPackageOfType()
{
$this->assertTrue($this->composer->isInstalledPackageOfType('composer/composer', 'library'));
}

/**
* Test getInstalledTestPackages()
*/
public function testGetInstalledTestPackages()
{
$output = $this->composer->getInstalledTestPackages();
$this->assertCount(1, $output);
$this->assertArrayHasKey('magento/module2-functional-test', $output);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/

namespace tests\unit\Magento\FunctionalTestFramework\Test\Util;

use Magento\FunctionalTestingFramework\Composer\ComposerPackage;
use Magento\FunctionalTestingFramework\Util\MagentoTestCase;
use Composer\Package\RootPackage;

class ComposerPackageTest extends MagentoTestCase
{
/**
* ComposerPackage instance to be tested
*
* @var ComposerPackage
*/
private $composer;

public function setUp()
{
$composerJson = dirname(__DIR__) . DIRECTORY_SEPARATOR . 'Composer' . DIRECTORY_SEPARATOR . '_files'
. DIRECTORY_SEPARATOR . 'dir1' . DIRECTORY_SEPARATOR . 'dir2' . DIRECTORY_SEPARATOR . 'composer.json';

$this->composer = new ComposerPackage($composerJson);
}

/**
* Test getName()
*/
public function testGetName()
{
$expected = 'magento/module2-functional-test';
$this->assertEquals($expected, $this->composer->getName());
}

/**
* Test getType()
*/
public function testGetType()
{
$expected = 'magento2-functional-test-module';
$this->assertEquals($expected, $this->composer->getType());
}

/**
* Test getVersion()
*/
public function testGetVersion()
{
$expected = '1.0.0';
$this->assertEquals($expected, $this->composer->getVersion());
}

/**
* Test getDescription()
*/
public function testGetDescription()
{
$expected = 'MFTF tests for magento';
$this->assertEquals($expected, $this->composer->getDescription());
}

/**
* Test getRequires()
*/
public function testGetRequires()
{
$expected = 'magento/magento2-functional-testing-framework';
$output = $this->composer->getRequires();
$this->assertCount(1, $output);
$this->assertArrayHasKey($expected, $output);
}

/**
* Test getDevRequires()
*/
public function testGetDevRequires()
{
$expected = ['phpunit/phpunit'];
$this->assertEquals($expected, array_keys($this->composer->getDevRequires()));
}

/**
* Test getSuggests()
*/
public function testGetSuggests()
{
$expected = [
'magento/module-one',
'magento/module-module-x',
'magento/module-two',
'magento/module-module-y',
'magento/module-module-z',
'magento/module-three',
'magento/module-four'
];
$this->assertEquals($expected, array_keys($this->composer->getSuggests()));
}

/**
* Test getSuggestedMagentoModules()
*/
public function testGetSuggestedMagentoModules()
{
$expected = [
'Magento_ModuleX',
'Magento_ModuleY',
'Magento_ModuleZ'
];
$this->assertEquals($expected, $this->composer->getSuggestedMagentoModules());
}

/**
* Test isMftfTestPackage()
*/
public function testIsMftfTestPackage()
{
$this->assertTrue($this->composer->isMftfTestPackage());
}

/**
* Test getRequiresForPackage()
*/
public function testGetRequiresForPackage()
{
$expected = [
'php',
'ext-curl',
'allure-framework/allure-codeception',
'codeception/codeception',
'consolidation/robo',
'csharpru/vault-php',
'csharpru/vault-php-guzzle6-transport',
'flow/jsonpath',
'fzaninotto/faker',
'monolog/monolog',
'mustache/mustache',
'symfony/process',
'vlucas/phpdotenv'
];
$this->assertEquals(
$expected,
array_keys($this->composer->getRequiresForPackage('magento/magento2-functional-testing-framework', '2.5.0'))
);
}

/**
* Test isPackageRequiredInComposerJson()
*/
public function testIsPackageRequiredInComposerJson()
{
$this->assertTrue(
$this->composer->isPackageRequiredInComposerJson('magento/magento2-functional-testing-framework')
);
}

/**
* Test getRootPackage()
*/
public function testGetRootPackage()
{
$this->assertInstanceOf(
RootPackage::class,
$this->composer->getRootPackage()
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "magento/module2-functional-test",
"type": "magento2-functional-test-module",
"description": "MFTF tests for magento",
"version": "1.0.0",
"require": {
"magento/magento2-functional-testing-framework": "^2.5.0"
},
"require-dev": {
"phpunit/phpunit": "~6.5.0 || ~7.0.0"
},
"suggest": {
"magento/module-one": "name: Magento_ModuleY, version: ~100.0.0",
"magento/module-module-x": " type: magento2-module ,name: Magento_ModuleX, version: ~100.0.0",
"magento/module-two": "*",
"magento/module-module-y": "type: magento2-module, name:Magento_ModuleY,version:~100.0.0",
"magento/module-module-z": " type:magento2-module, name: Magento_ModuleZ , version: ~100.0.0",
"magento/module-three": "type: magento2-module, ~100.0.0",
"magento/module-four": "some suggestions"
}
}
Loading