/** * The Constructor. * * @param object|string $reference An instance or a fully-namespaced class name. */ public function __construct($reference, $static = false) { $this->_reference = $reference; if (is_object($reference)) { Suite::register(get_class($reference)); } Suite::register(Suite::hash($reference)); }
/** * Constructor * * @param string|object $actual A fully-namespaced class name or an object instance. * @param string $expected The expected method method name to be called. */ public function __construct($actual) { $actual = ltrim($actual, '\\'); $this->_actual = $actual; Suite::register(Suite::hash($actual)); $this->_message = new Message(['name' => $actual]); $this->_backtrace = Debugger::backtrace(); }
/** * Clears the registered references. * * @param string $reference An instance or a fully namespaced class name or `null` to clear all. */ public static function reset($reference = null) { if ($reference === null) { static::$_registered = []; Suite::reset(); return; } unset(static::$_registered[Suite::hash($reference)]); }
$hash = Suite::hash($instance); Suite::register($hash); expect(Suite::registered($hash))->toBe(true); }); }); describe("::register()", function () { it("return `false` if the hash is not registered", function () { $instance = new stdClass(); $hash = Suite::hash($instance); expect(Suite::registered($hash))->toBe(false); }); }); describe("::reset()", function () { it("clears registered hashes", function () { $instance = new stdClass(); $hash = Suite::hash($instance); Suite::register($hash); expect(Suite::registered($hash))->toBe(true); Suite::reset(); expect(Suite::registered($hash))->toBe(false); }); }); describe("->status()", function () { it("returns `0` if a specs suite passes", function () { $describe = $this->suite->describe("", function () { $this->it("passes", function () { $this->expect(true)->toBe(true); }); }); $this->suite->run(); expect($this->suite->status())->toBe(0);
/** * Watch a message. * * @param string|object $actual A fully-namespaced class name or an object instance. * @param string $method The expected method method name to be called. * @param object A message instance. */ protected function _watch($message) { $reference = $message->reference(); if (!$reference) { Suite::register($message->name()); return $message; } if (is_object($reference)) { Suite::register(get_class($reference)); } Suite::register(Suite::hash($reference)); return $message; }