Guest User

Untitled

a guest
Jan 22nd, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2. class AwesomeAppTest extends CakeTestCase {
  3. public $skipSetup = false;
  4. public $testMethods = array();
  5. public function getTests() {
  6. $mergeTests = array();
  7. $tests = parent::getTests();
  8. $testFlags = array('run', 'test', 'tests');
  9.  
  10. if (php_sapi_name() == 'cli') {
  11. foreach ($_SERVER['argv'] as $arg) {
  12. foreach ($testFlags as $name) {
  13. if (substr($arg, 0, strlen($name) + 2) == "-{$name}=") {
  14. $this->testMethods = substr($arg, strlen($name) + 2);
  15. if ($this->testMethods[0] == '[') {
  16. $this->testMethods = explode(',', substr($this->testMethods, 1, -1));
  17. }
  18. break;
  19. }
  20. }
  21. }
  22. } else {
  23. foreach ($testFlags as $name) {
  24. if (isset($_GET[$name])) {
  25. $this->testMethods = $_GET[$name];
  26. break;
  27. }
  28. }
  29. }
  30.  
  31. $this->testMethods = (array) $this->testMethods;
  32. foreach ((array) $this->testMethods as $k => $testName) {
  33. $this->testMethods[$k] = 'test' . Inflector::camelize($testName);
  34. if (!in_array($this->testMethods[$k], $tests)) {
  35. unset($this->testMethods[$k]);
  36. }
  37. }
  38.  
  39. $start = array('start' => 'start', 'startCase' => 'startCase');
  40. $end = array('endCase' => 'endCase', 'end' => 'end');
  41. if (isset($this->skipSetup) && $this->skipSetup) {
  42. unset($start['start'], $end['end']);
  43. }
  44.  
  45. if (empty($this->testMethods)) {
  46. return array_merge(array_keys($start), $tests, array_keys($end));
  47. }
  48.  
  49. foreach ($tests as $name) {
  50. if (!in_array($name, $this->testMethods) && !isset($start[$name]) && !isset($end[$name])) {
  51. $this->_reporter->paintSkip(sprintf(__('Entire Test Method: %s', true), $name));
  52. }
  53. }
  54.  
  55. return array_merge(array_keys($start), $this->testMethods, array_keys($end));
  56. }
  57.  
  58. }
Add Comment
Please, Sign In to add comment