AbstractObject::runTests PHP Method

runTests() public method

$test will be an array containing keys for 'name', 'object' and 'class'
public runTests ( Tester $tester = null )
$tester Tester
    public function runTests(Tester $tester = null)
    {
        $test = array('object' => $this->name, 'class' => get_class($this));
        foreach (get_class_methods($this) as $method) {
            if (strpos($method, 'test_') === 0) {
                $test['name'] = substr($method, 5);
            } else {
                continue;
            }
            if ($tester && $tester->prepareForTest($test) === false) {
                continue;
            }
            if ($tester !== null) {
                /** @type Model $r */
                $r = $tester->results;
                $r->unload();
                $r->set($test);
            }
            // Proceed with test
            $me = memory_get_peak_usage();
            $ms = microtime(true);
            $this->_ticks = 0;
            declare (ticks=1);
            register_tick_function(array($this, '_ticker'));
            // Execute here
            try {
                $result = $this->{$method}($tester);
            } catch (Exception $e) {
                unregister_tick_function(array($this, '_ticker'));
                $time = microtime(true) - $ms;
                $memory = memory_get_peak_usage() - $me;
                $ticks = $this->_ticks;
                if ($e instanceof Exception_SkipTests) {
                    if ($tester !== null) {
                        $r['exception'] = 'SKIPPED';
                        $r->saveAndUnload();
                    }
                    return array('skipped' => $e->getMessage());
                }
                if ($tester !== null) {
                    $r['time'] = $time;
                    $r['memory'] = $memory;
                    $r['ticks'] = $ticks;
                    $r['exception'] = $e;
                    $r->saveAndUnload();
                }
                continue;
            }
            // Unregister
            unregister_tick_function(array($this, '_ticker'));
            $time = microtime(true) - $ms;
            $memory = memory_get_peak_usage() - $me;
            $ticks = $this->_ticks - 3;
            // there are always minimum of 3 ticks
            if ($tester !== null) {
                $r['time'] = $time;
                $r['memory'] = $memory;
                $r['ticks'] = $ticks;
                $r['is_success'] = true;
                $r['result'] = $result;
                $r->saveAndUnload();
            }
        }
    }