Файл: vkolhoze.com/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CurlBackoffStrategyTest.php
Строк: 27
<?php
namespace GuzzleTestsPluginBackoff;
use GuzzleHttpMessageResponse;
use GuzzlePluginBackoffCurlBackoffStrategy;
use GuzzleHttpExceptionCurlException;
/**
* @covers GuzzlePluginBackoffCurlBackoffStrategy
* @covers GuzzlePluginBackoffAbstractErrorCodeBackoffStrategy
*/
class CurlBackoffStrategyTest extends GuzzleTestsGuzzleTestCase
{
public function testRetriesWithExponentialDelay()
{
$this->assertNotEmpty(CurlBackoffStrategy::getDefaultFailureCodes());
$strategy = new CurlBackoffStrategy();
$this->assertTrue($strategy->makesDecision());
$request = $this->getMock('GuzzleHttpMessageRequest', array(), array(), '', false);
$e = new CurlException();
$e->setError('foo', CURLE_BAD_CALLING_ORDER);
$this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, null, $e));
foreach (CurlBackoffStrategy::getDefaultFailureCodes() as $code) {
$this->assertEquals(0, $strategy->getBackoffPeriod(0, $request, null, $e->setError('foo', $code)));
}
}
public function testIgnoresNonErrors()
{
$strategy = new CurlBackoffStrategy();
$request = $this->getMock('GuzzleHttpMessageRequest', array(), array(), '', false);
$this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, new Response(200)));
}
}