public function testReturnsZeroWhenDecisionMakerReturnsTrueButNoFurtherStrategiesAreInTheChain() { $a = new CallbackBackoffStrategy(function () { return null; }, true); $b = new CallbackBackoffStrategy(function () { return true; }, true); $a->setNext($b); $this->assertSame(0, $a->getBackoffPeriod(2, new Request('GET', 'http://www.foo.com'))); }
public function testRetriesWithCallable() { $request = $this->getMock('Guzzle\\Http\\Message\\Request', array(), array(), '', false); $strategy = new CallbackBackoffStrategy(function () { return 10; }, true); $this->assertTrue($strategy->makesDecision()); $this->assertEquals(10, $strategy->getBackoffPeriod(0, $request)); // Ensure it chains correctly when null is returned $strategy = new CallbackBackoffStrategy(function () { return null; }, false); $this->assertFalse($strategy->makesDecision()); $this->assertFalse($strategy->getBackoffPeriod(0, $request)); }