-
Notifications
You must be signed in to change notification settings - Fork 132
/
Copy pathStaticChecksList.php
96 lines (86 loc) · 2.82 KB
/
StaticChecksList.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);
namespace Magento\FunctionalTestingFramework\StaticCheck;
use Magento\FunctionalTestingFramework\Exceptions\TestFrameworkException;
use Magento\FunctionalTestingFramework\Util\Path\FilePathFormatter;
/**
* Class StaticChecksList has a list of static checks to run on test xml
* @codingStandardsIgnoreFile
*/
class StaticChecksList implements StaticCheckListInterface
{
const DEPRECATED_ENTITY_USAGE_CHECK_NAME = 'deprecatedEntityUsage';
const PAUSE_ACTION_USAGE_CHECK_NAME = 'pauseActionUsage';
const CREATED_DATA_FROM_OUTSIDE_ACTIONGROUP = 'createdDataFromOutsideActionGroup';
const UNUSED_ENTITY_CHECK = 'unusedEntityCheck';
const STATIC_RESULTS = 'tests' . DIRECTORY_SEPARATOR .'_output' . DIRECTORY_SEPARATOR . 'static-results';
/**
* Property contains all static check scripts.
*
* @var StaticCheckInterface[]
*/
private $checks;
/**
* Directory path for static checks error files
*
* @var string
*/
private static $errorFilesPath = null;
/**
* Constructor
*
* @param array $checks
* @throws TestFrameworkException
*/
public function __construct(array $checks = [])
{
$this->checks = [
'testDependencies' => new TestDependencyCheck(),
'actionGroupArguments' => new ActionGroupStandardsCheck(),
self::DEPRECATED_ENTITY_USAGE_CHECK_NAME => new DeprecatedEntityUsageCheck(),
'annotations' => new AnnotationsCheck(),
self::PAUSE_ACTION_USAGE_CHECK_NAME => new PauseActionUsageCheck(),
self::UNUSED_ENTITY_CHECK => new UnusedEntityCheck(),
self::CREATED_DATA_FROM_OUTSIDE_ACTIONGROUP => new CreatedDataFromOutsideActionGroupCheck(),
] + $checks;
// Static checks error files directory
if (null === self::$errorFilesPath) {
self::$errorFilesPath = FilePathFormatter::format(TESTS_BP) . self::STATIC_RESULTS;
}
}
/**
* {@inheritdoc}
*/
public function getStaticChecks()
{
return $this->checks;
}
/**
* Return the directory path for the static check error files
*/
public static function getErrorFilesPath()
{
return self::$errorFilesPath;
}
/**
* Return relative path to files for unit testing purposes.
* @param string $fileNames
* @return string
*/
public static function getFilePath($fileNames)
{
if (!empty($fileNames)) {
$relativeFileNames = ltrim(
str_replace(MAGENTO_BP, '', $fileNames)
);
if (!empty($relativeFileNames)) {
return $relativeFileNames;
}
}
return $fileNames;
}
}