public function test_ShouldFailOnTooManyConsecutiveFailsAndNotBefore() { $maxFails = 10; $rp = new RotatingProxy("test", null, $maxFails, -1, null); for ($i = 0; $i < $maxFails - 1; $i++) { $rp->failed(); } $this->assertFalse($rp->hasTooManyConsecutiveFails(), "Expected NOT to have enough consecutive fails"); $rp->failed(); $this->assertTrue($rp->hasTooManyConsecutiveFails(), "Expected to have enough consecutive fails"); $rp->setMaxConsecutiveFails(-1); $this->assertFalse($rp->hasTooManyTotalFails(), "Expected NOT to have enough consecutive fails since it inifite fails should be allowed"); $rp->setMaxConsecutiveFails($maxFails); $rp->setCurrentConsecutiveFails(0); for ($i = 0; $i < $maxFails - 1; $i++) { $rp->failed(); } $this->assertFalse($rp->hasTooManyConsecutiveFails("Expected NOT to have enough consecutive fails after resetting")); $rp->succeeded(); $rp->failed(); $this->assertFalse($rp->hasTooManyConsecutiveFails("Expected NOT to have enough consecutive fails after succeeding")); }