Вход Регистрация
Файл: vkolhoze.com/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/HttpBackoffStrategyTest.php
Строк: 34
<?php

namespace GuzzleTestsPluginBackoff;

use 
GuzzlePluginBackoffHttpBackoffStrategy;
use 
GuzzleHttpMessageResponse;

/**
 * @covers GuzzlePluginBackoffHttpBackoffStrategy
 * @covers GuzzlePluginBackoffAbstractErrorCodeBackoffStrategy
 */
class HttpBackoffStrategyTest extends GuzzleTestsGuzzleTestCase
{
    public function 
testRetriesWhenCodeMatches()
    {
        
$this->assertNotEmpty(HttpBackoffStrategy::getDefaultFailureCodes());
        
$strategy = new HttpBackoffStrategy();
        
$this->assertTrue($strategy->makesDecision());
        
$request $this->getMock('GuzzleHttpMessageRequest', array(), array(), ''false);

        
$response = new Response(200);
        
$this->assertEquals(false$strategy->getBackoffPeriod(0$request$response));
        
$response->setStatus(400);
        
$this->assertEquals(false$strategy->getBackoffPeriod(0$request$response));

        foreach (
HttpBackoffStrategy::getDefaultFailureCodes() as $code) {
            
$this->assertEquals(0$strategy->getBackoffPeriod(0$request$response->setStatus($code)));
        }
    }

    public function 
testAllowsCustomCodes()
    {
        
$strategy = new HttpBackoffStrategy(array(204));
        
$request $this->getMock('GuzzleHttpMessageRequest', array(), array(), ''false);
        
$response = new Response(204);
        
$this->assertEquals(0$strategy->getBackoffPeriod(0$request$response));
        
$response->setStatus(500);
        
$this->assertEquals(false$strategy->getBackoffPeriod(0$request$response));
    }

    public function 
testIgnoresNonErrors()
    {
        
$strategy = new HttpBackoffStrategy();
        
$request $this->getMock('GuzzleHttpMessageRequest', array(), array(), ''false);
        
$this->assertEquals(false$strategy->getBackoffPeriod(0$request));
    }
}
Онлайн: 0
Реклама