AbstractRetryableEventTest.php
1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
namespace GuzzleHttp\Tests\Event;
use GuzzleHttp\Client;
use GuzzleHttp\Transaction;
use GuzzleHttp\Message\Request;
/**
* @covers GuzzleHttp\Event\AbstractRetryableEvent
*/
class AbstractRetryableEventTest extends \PHPUnit_Framework_TestCase
{
public function testCanRetry()
{
$t = new Transaction(new Client(), new Request('GET', '/'));
$t->transferInfo = ['foo' => 'bar'];
$e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRetryableEvent')
->setConstructorArgs([$t])
->getMockForAbstractClass();
$e->retry();
$this->assertTrue($e->isPropagationStopped());
$this->assertEquals('retry', $t->state);
}
public function testCanRetryAfterDelay()
{
$t = new Transaction(new Client(), new Request('GET', '/'));
$t->transferInfo = ['foo' => 'bar'];
$e = $this->getMockBuilder('GuzzleHttp\Event\AbstractRetryableEvent')
->setConstructorArgs([$t])
->getMockForAbstractClass();
$e->retry(10);
$this->assertTrue($e->isPropagationStopped());
$this->assertEquals('retry', $t->state);
$this->assertEquals(10, $t->request->getConfig()->get('delay'));
}
}