Unit.php 827 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Helper;
  3. use Codeception\Module;
  4. use Codeception\Module\Filesystem;
  5. class Unit extends Module
  6. {
  7. public function _beforeSuite($settings = [])
  8. {
  9. $chartDir = $this->getChartDirectoryPath();
  10. if (!is_dir($chartDir)) {
  11. mkdir($chartDir);
  12. }
  13. $this->clearOutputDirectory();
  14. }
  15. public function _afterSuite($settings = [])
  16. {
  17. $this->clearOutputDirectory();
  18. }
  19. private function clearOutputDirectory()
  20. {
  21. $this->getFileSystem()->cleanDir($this->getChartDirectoryPath());
  22. }
  23. private function getChartDirectoryPath()
  24. {
  25. return sprintf(__DIR__."/../../_output/charts");
  26. }
  27. /**
  28. * @return Filesystem
  29. */
  30. private function getFileSystem()
  31. {
  32. return $this->getModule('Filesystem');
  33. }
  34. }