CliHelper.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace Codeception\Module;
  3. // here you can define custom functions for CliGuy
  4. class CliHelper extends \Codeception\Module
  5. {
  6. public function _beforeSuite($settings = [])
  7. {
  8. $this->debug('Building actor classes for claypit');
  9. $this->getModule('Cli')->runShellCommand('php ' . codecept_root_dir() . 'codecept build -c ' . codecept_data_dir() . 'claypit');
  10. }
  11. public function _before(\Codeception\TestInterface $test)
  12. {
  13. codecept_debug('creating dirs');
  14. $this->getModule('Filesystem')->copyDir(codecept_data_dir() . 'claypit', codecept_data_dir() . 'sandbox');
  15. }
  16. public function _after(\Codeception\TestInterface $test)
  17. {
  18. codecept_debug('deleting dirs');
  19. $this->getModule('Filesystem')->deleteDir(codecept_data_dir() . 'sandbox');
  20. chdir(\Codeception\Configuration::projectDir());
  21. }
  22. public function executeCommand($command, $fail = true)
  23. {
  24. $this->getModule('Cli')->runShellCommand('php ' . \Codeception\Configuration::projectDir() . 'codecept ' . $command . ' -n', $fail);
  25. }
  26. public function executeFailCommand($command)
  27. {
  28. $this->getModule('Cli')->runShellCommand('php '.\Codeception\Configuration::projectDir().'codecept '.$command.' -n', false);
  29. }
  30. public function seeDirFound($dir)
  31. {
  32. $this->assertTrue(is_dir($dir) && file_exists($dir), "Directory does not exist");
  33. }
  34. }