/** * @covers ::now */ public function testDoesNotExecuteCallbackIfContractsDisabled() { // ---------------------------------------------------------------- // setup your test $executed = false; $callback = function () use(&$executed) { $executed = true; }; ContractChecks::disable(); // ---------------------------------------------------------------- // perform the change CheckContracts::now($callback, []); // ---------------------------------------------------------------- // test the results $this->assertFalse($executed); }
/** * @covers ::areContractsEnabled */ public function testCanCheckThatContractsAreEnabled() { // ---------------------------------------------------------------- // setup your test ContractChecks::enable(); $this->assertTrue(ContractChecks::areEnabled()); $this->assertTrue(Contracts::areContractsEnabled()); // ---------------------------------------------------------------- // perform the change ContractChecks::disable(); // ---------------------------------------------------------------- // test the results $this->assertFalse(ContractChecks::areEnabled()); $this->assertFalse(Contracts::areContractsEnabled()); }
/** * are the '::requireThat()', '::ensureThat()' and '::checkThat()' methods * enforcing their contacts? * * @return boolean * TRUE if these methods run their contacts * FALSE if these methods skip over their contracts */ public static function areContractsEnabled() { return ContractChecks::areEnabled(); }