Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DataProviderFromFile.php
Go to the documentation of this file.
1 <?php
8 
12 
17 {
21  private $moduleManager;
22 
26  private $cliCommand;
27 
31  public function __construct()
32  {
33  $this->moduleManager = new TestModuleManager();
34  $this->cliCommand = new CliCommand($this->moduleManager);
35  }
36 
43  public function startTest(\PHPUnit\Framework\TestCase $test)
44  {
45  $annotations = $test->getAnnotations();
46  //This annotation can be declared only on method level
47  if (isset($annotations['method']['dataProviderFromFile']) && $test instanceof MutableDataInterface) {
48  $data = include TESTS_MODULES_PATH . "/" . $annotations['method']['dataProviderFromFile'][0];
49  $test->setData($data);
50  } else if (!$test instanceof MutableDataInterface) {
51  throw new \Exception("Test type do not supports @dataProviderFromFile annotation");
52  }
53  }
54 
61  public function endTest(\PHPUnit\Framework\TestCase $test)
62  {
63  if ($test instanceof MutableDataInterface) {
64  $test->flushData();
65  }
66  }
67 }