/** * @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()); }
/** * tell the Contracts Library *not* to check the contracts in the * '::requireThat()', '::ensureThat()' and '::checkThat()' methods * * @return void */ public static function disableContracts() { ContractChecks::disable(); }