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
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\TestFramework\Bootstrap;
use Magento\TestFramework\Application;
/**
* Bootstrap of the custom DocBlock annotations
*
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class DocBlock
{
/**
* @var string
*/
protected $_fixturesBaseDir;
/**
* @param string $fixturesBaseDir
*/
public function __construct($fixturesBaseDir)
{
$this->_fixturesBaseDir = $fixturesBaseDir;
}
/**
* Activate custom DocBlock annotations along with more-or-less permanent workarounds
* @param Application $application
*/
public function registerAnnotations(Application $application)
{
$eventManager = new \Magento\TestFramework\EventManager($this->_getSubscribers($application));
\Magento\TestFramework\Event\PhpUnit::setDefaultEventManager($eventManager);
\Magento\TestFramework\Event\Magento::setDefaultEventManager($eventManager);
}
/**
* Get list of subscribers.
*
* Note: order of registering (and applying) annotations is important.
* To allow config fixtures to deal with fixture stores, data fixtures should be processed first.
* ConfigFixture applied twice because data fixtures could clean config and clean custom settings
*
* @param Application $application
* @return array
*/
protected function _getSubscribers(Application $application)
{
return [
new \Magento\TestFramework\Workaround\Segfault(),
new \Magento\TestFramework\Workaround\Cleanup\TestCaseProperties(),
new \Magento\TestFramework\Workaround\Cleanup\StaticProperties(),
new \Magento\TestFramework\Isolation\WorkingDirectory(),
new \Magento\TestFramework\Isolation\DeploymentConfig(),
new \Magento\TestFramework\Annotation\AppIsolation($application),
new \Magento\TestFramework\Annotation\IndexerDimensionMode($application),
new \Magento\TestFramework\Isolation\AppConfig(),
new \Magento\TestFramework\Annotation\ConfigFixture(),
new \Magento\TestFramework\Annotation\DataFixtureBeforeTransaction($this->_fixturesBaseDir),
new \Magento\TestFramework\Event\Transaction(
new \Magento\TestFramework\EventManager(
[
new \Magento\TestFramework\Annotation\DbIsolation(),
new \Magento\TestFramework\Annotation\DataFixture($this->_fixturesBaseDir),
]
)
),
new \Magento\TestFramework\Annotation\ComponentRegistrarFixture($this->_fixturesBaseDir),
new \Magento\TestFramework\Annotation\AppArea($application),
new \Magento\TestFramework\Annotation\Cache($application),
new \Magento\TestFramework\Annotation\AdminConfigFixture(),
new \Magento\TestFramework\Annotation\ConfigFixture(),
];
}
}