31 private $appliedFixtures = [];
42 throw new \Magento\Framework\Exception\LocalizedException(
55 public function startTest(\PHPUnit\Framework\TestCase $test)
67 public function endTest(\PHPUnit\Framework\TestCase $test)
82 protected function _getFixtures(\PHPUnit\Framework\TestCase $test, $scope =
null)
84 if ($scope ===
null) {
85 $annotations = $this->getAnnotations($test);
87 $annotations = $test->getAnnotations()[$scope];
90 if (!empty($annotations[
'magentoSchemaFixture'])) {
91 foreach ($annotations[
'magentoSchemaFixture'] as $fixture) {
92 if (strpos($fixture,
'\\') !==
false) {
94 throw new \Magento\Framework\Exception\LocalizedException(
95 new \
Magento\Framework\
Phrase(
'Directory separator "\\" is prohibited in fixture declaration.')
98 $fixtureMethod = [get_class($test), $fixture];
99 if (is_callable($fixtureMethod)) {
102 $result[] = $this->fixtureBaseDir .
'/' . $fixture;
115 private function getAnnotations(\PHPUnit\Framework\TestCase $test)
117 $annotations = $test->getAnnotations();
118 return array_replace($annotations[
'class'], $annotations[
'method']);
130 if (is_callable($fixture)) {
135 }
catch (\Exception $e) {
136 throw new \Exception(
137 sprintf(
"Error in fixture: %s.\n %s", json_encode($fixture), $e->getMessage()),
153 foreach ($fixtures as $oneFixture) {
155 if (in_array($oneFixture, $this->appliedFixtures,
true)) {
159 $this->appliedFixtures[] = $oneFixture;
168 foreach ($this->appliedFixtures as $fixture) {
169 if (is_callable($fixture)) {
170 $fixture[1] .=
'Rollback';
171 if (is_callable($fixture)) {
181 if (file_exists($rollbackScript)) {
186 $this->appliedFixtures = [];
call_user_func($callable, $param)
_getFixtures(\PHPUnit\Framework\TestCase $test, $scope=null)
startTest(\PHPUnit\Framework\TestCase $test)
__construct($fixtureBaseDir)
_applyOneFixture($fixture)
endTest(\PHPUnit\Framework\TestCase $test)
_applyFixtures(array $fixtures)