Example #1
0
 /**
  * Applies focus up to the root.
  */
 protected function _emitFocus()
 {
     $this->_root->_focuses[] = Debugger::focus($this->backtraceFocus(), Debugger::backtrace());
     $instances = $this->_parents(true);
     foreach ($instances as $instance) {
         $instance->focus();
     }
 }
Example #2
0
 /**
  * Helper which extracts the backtrace of a report.
  *
  * @param array $data The report data.
  */
 public function _backtrace($data)
 {
     if (isset($data['exception'])) {
         return Debugger::backtrace(['trace' => $data['exception']]);
     }
     $type = $data['type'];
     $depth = $type === 'pass' || $type === 'fail' | $type === 'skip' ? 1 : null;
     if (!isset($data['backtrace'])) {
         $data['backtrace'] = [];
     }
     return Debugger::focus($this->scope()->backtraceFocus(), $data['backtrace'], $depth);
 }
Example #3
0
 /**
  * Adds an expectation report and emits a report event.
  *
  * @param array $data The report data.
  */
 public function add($type, $data = [])
 {
     if ($this->type() === 'passed' && $type === 'failed') {
         $this->type('failed');
     }
     $data['type'] = $type;
     if (!isset($data['backtrace'])) {
         $data['backtrace'] = [];
     } else {
         $data['backtrace'] = Debugger::focus($this->scope()->backtraceFocus(), $data['backtrace'], 1);
     }
     $child = new static($data + ['scope' => $this->_scope]);
     $this->_children[] = $child;
     return $child;
 }
Example #4
0
 /**
  * The Constructor.
  *
  * @param array $config The Suite config array. Options are:
  *                       -`'type'`    _string_ : supported type are `'normal'` & `'focus'`.
  *                       -`'message'` _string_ : the description message.
  *                       -`'parent'`  _object_ : the parent scope.
  *                       -`'root'`    _object_ : the root scope.
  *                       -`'log'`     _object_ : the log instance.
  *                       -`'timeout'` _integer_: the timeout.
  */
 public function __construct($config = [])
 {
     $defaults = ['type' => 'normal', 'message' => '', 'parent' => null, 'root' => null, 'log' => null, 'timeout' => 0, 'summary' => null];
     $config += $defaults;
     $this->_type = $config['type'];
     $this->_message = $config['message'];
     $this->_parent = $config['parent'];
     $this->_root = $this->_parent ? $this->_parent->_root : $this;
     $this->_timeout = $config['timeout'];
     $this->_backtrace = Debugger::focus($this->backtraceFocus(), Debugger::backtrace(), 1);
     $this->_log = $config['log'] ?: new Log(['scope' => $this, 'backtrace' => $this->_backtrace]);
     $this->_summary = $config['summary'];
     if ($this->_summary) {
         return;
     }
     if ($this->_root->summary()) {
         $this->_summary = $this->_root->summary();
     } else {
         $this->_summary = new Summary();
     }
 }