27 private $_appliedFixtures = [];
38 throw new \Magento\Framework\Exception\LocalizedException(
50 public function startTest(\PHPUnit\Framework\TestCase $test)
60 public function endTest()
76 protected function _getFixtures($scope, \PHPUnit\Framework\TestCase $test)
78 $annotations = $test->getAnnotations();
80 if (!empty($annotations[$scope][
'magentoApiDataFixture'])) {
81 foreach ($annotations[$scope][
'magentoApiDataFixture'] as $fixture) {
82 if (strpos($fixture,
'\\') !==
false) {
84 throw new \Magento\Framework\Exception\LocalizedException(
85 __(
'Directory separator "\\" is prohibited in fixture declaration.')
88 $fixtureMethod = [get_class($test), $fixture];
89 if (is_callable($fixtureMethod)) {
92 $result[] = $this->_fixtureBaseDir .
'/' . $fixture;
108 if (is_callable($fixture)) {
113 }
catch (\Exception $e) {
114 throw new \Exception(
116 "Exception occurred when running the %s fixture: \n%s",
117 (\is_array($fixture) || is_scalar($fixture) ? json_encode($fixture) :
'callback'),
122 $this->_appliedFixtures[] = $fixture;
134 foreach ($fixtures as $oneFixture) {
136 if (!in_array($oneFixture, $this->_appliedFixtures,
true)) {
147 $appliedFixtures = array_reverse($this->_appliedFixtures);
148 foreach ($appliedFixtures as $fixture) {
149 if (is_callable($fixture)) {
150 $fixture[1] .=
'Rollback';
151 if (is_callable($fixture)) {
161 if (file_exists($rollbackScript)) {
166 $this->_appliedFixtures = [];
_getFixtures($scope, \PHPUnit\Framework\TestCase $test)
call_user_func($callable, $param)
startTest(\PHPUnit\Framework\TestCase $test)
_applyOneFixture($fixture)
__construct($fixtureBaseDir)
static getObjectManager()
_applyFixtures(array $fixtures)