kahlan\Scope::__construct PHP Method

__construct() public method

The Constructor.
public __construct ( array $config = [] )
$config array 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();
        }
    }

Usage Example

Example #1
0
 /**
  * Constructor.
  *
  * @param array $config The Suite config array. Options are:
  *                       -`'closure'` _Closure_ : the closure of the test.
  *                       -`'scope'`   _string_  : supported scope are `'normal'` & `'focus'`.
  *                       -`'matcher'` _object_  : the matcher instance.
  */
 public function __construct($config = [])
 {
     $defaults = ['closure' => null, 'message' => 'passes', 'scope' => 'normal'];
     $config += $defaults;
     $config['message'] = 'it ' . $config['message'];
     parent::__construct($config);
     extract($config);
     $this->_closure = $this->_bind($closure, 'it');
     if ($scope === 'focus') {
         $this->_emitFocus();
     }
 }
All Usage Examples Of kahlan\Scope::__construct