25 '/dev/tests/integration/framework' => [],
36 \Magento\Framework\App\ObjectManager::class,
37 \Magento\TestFramework\Helper\Bootstrap::class,
38 \Magento\TestFramework\Event\Magento::class,
39 \Magento\TestFramework\Event\PhpUnit::class,
40 \Magento\TestFramework\Annotation\AppIsolation::class,
41 \Magento\TestFramework\Workaround\Cleanup\StaticProperties::class,
42 \Magento\Framework\Phrase::class,
48 public function __construct()
53 $key = $moduleDir .
'/';
54 $value = $key .
'Test/Unit/';
55 self::$_cleanableFolders[$key] = [
$value];
58 $key = $libraryDir .
'/';
59 $valueRootFolder = $key .
'/Test/Unit/';
60 $valueSubFolder = $key .
'/*/Test/Unit/';
61 self::$_cleanableFolders[$key] = [$valueSubFolder, $valueRootFolder];
74 foreach (self::$_classesToSkip as $notCleanableClass) {
94 $classFile = str_replace(
'\\',
'/', $classFile);
95 foreach (self::$_cleanableFolders as $include => $excludeSet) {
96 if (stripos($classFile, $include) !==
false) {
97 foreach ($excludeSet as $exclude) {
98 $excludeExp =
'#' . str_replace(
'*',
'[\w]+', $exclude) .
'#';
99 if (preg_match($excludeExp, $classFile)) {
118 private static function getReflectionClass(
$class)
120 if (!isset(self::$classes[
$class])) {
123 return self::$classes[
$class];
132 foreach (array_keys(self::$backupStaticVariables) as
$class) {
134 $staticProperties =
$reflectionClass->getProperties(\ReflectionProperty::IS_STATIC);
135 foreach ($staticProperties as $staticProperty) {
136 $staticProperty->setAccessible(
true);
137 $staticProperty->setValue(self::$backupStaticVariables[
$class][$staticProperty->getName()]);
148 if (count(self::$backupStaticVariables) > 0) {
151 $classFiles = array_filter(
157 function ($classFile) {
162 $namespacePattern =
'/namespace [a-zA-Z0-9\\\\]+;/';
163 $classPattern =
'/\nclass [a-zA-Z0-9_]+/';
164 foreach ($classFiles as $classFile) {
166 preg_match($namespacePattern,
$code, $namespace);
168 if (!isset($namespace[0]) || !isset(
$class[0])) {
172 $namespace = substr($namespace[0], 10, strlen($namespace[0]) - 11);
178 }
catch (\Exception $e) {
182 $staticProperties =
$reflectionClass->getProperties(\ReflectionProperty::IS_STATIC);
183 foreach ($staticProperties as $staticProperty) {
184 $staticProperty->setAccessible(
true);
185 $value = $staticProperty->getValue();
186 self::$backupStaticVariables[
$className][$staticProperty->getName()] =
$value;
198 if (empty(self::$backupStaticVariables)) {
210 $clearStatics =
false;
211 foreach ($suite->tests() as $test) {
212 if ($test instanceof \
Magento\TestFramework\TestCase\AbstractController) {
213 $clearStatics =
true;
is_subclass_of($obj, $className)
static backupStaticVariables()
endTestSuite(\PHPUnit\Framework\TestSuite $suite)
static _isClassInCleanableFolders($classFile)
static $backupStaticVariables
static $_cleanableFolders
$_option $_optionId $class
static _isClassCleanable(\ReflectionClass $reflectionClass)
static restoreStaticVariables()