/** * @covers ::now */ public function testPassesParamsIntoCallback() { // ---------------------------------------------------------------- // setup your test $expectedParam1 = 5; $expectedParam2 = 3.1415927; $executed = false; $callback = function ($param1, $param2) use(&$executed, $expectedParam1, $expectedParam2) { $this->assertEquals($expectedParam1, $param1); $this->assertEquals($expectedParam2, $param2); $executed = true; }; ContractChecks::enable(); // ---------------------------------------------------------------- // perform the change CheckContracts::now($callback, [$expectedParam1, $expectedParam2]); // ---------------------------------------------------------------- // test the results $this->assertTrue($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 to check the contracts in the * '::requireThat()', '::ensureThat()' and '::checkThat()' methods * * @return void */ public static function enableContracts() { ContractChecks::enable(); }