Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class AwesomeAppTest extends CakeTestCase {
- public $skipSetup = false;
- public $testMethods = array();
- public function getTests() {
- $mergeTests = array();
- $tests = parent::getTests();
- $testFlags = array('run', 'test', 'tests');
- if (php_sapi_name() == 'cli') {
- foreach ($_SERVER['argv'] as $arg) {
- foreach ($testFlags as $name) {
- if (substr($arg, 0, strlen($name) + 2) == "-{$name}=") {
- $this->testMethods = substr($arg, strlen($name) + 2);
- if ($this->testMethods[0] == '[') {
- $this->testMethods = explode(',', substr($this->testMethods, 1, -1));
- }
- break;
- }
- }
- }
- } else {
- foreach ($testFlags as $name) {
- if (isset($_GET[$name])) {
- $this->testMethods = $_GET[$name];
- break;
- }
- }
- }
- $this->testMethods = (array) $this->testMethods;
- foreach ((array) $this->testMethods as $k => $testName) {
- $this->testMethods[$k] = 'test' . Inflector::camelize($testName);
- if (!in_array($this->testMethods[$k], $tests)) {
- unset($this->testMethods[$k]);
- }
- }
- $start = array('start' => 'start', 'startCase' => 'startCase');
- $end = array('endCase' => 'endCase', 'end' => 'end');
- if (isset($this->skipSetup) && $this->skipSetup) {
- unset($start['start'], $end['end']);
- }
- if (empty($this->testMethods)) {
- return array_merge(array_keys($start), $tests, array_keys($end));
- }
- foreach ($tests as $name) {
- if (!in_array($name, $this->testMethods) && !isset($start[$name]) && !isset($end[$name])) {
- $this->_reporter->paintSkip(sprintf(__('Entire Test Method: %s', true), $name));
- }
- }
- return array_merge(array_keys($start), $this->testMethods, array_keys($end));
- }
- }
Add Comment
Please, Sign In to add comment