Completed
Push — master ( abd222...dd8eb0 )
by Benjamin
02:03
created

AgentTest::testSomething()   B

Complexity

Conditions 3
Paths 4

Size

Total Lines 28
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
c 4
b 0
f 1
dl 0
loc 28
rs 8.8571
cc 3
eloc 16
nc 4
nop 0
1
<?php
2
3
namespace CurlX\Tests;
4
5
use CurlX\Agent;
6
use CurlX\RequestInterface;
7
use PHPUnit_Framework_TestCase;
8
9
class AgentTest extends PHPUnit_Framework_TestCase
10
{
11
    public function setUp()
12
    {
13
14
    }
15
16
    public function tearDown()
17
    {
18
19
    }
20
21
    public function testSomething()
22
    {
23
        $agent = new Agent(10);
24
25
        $called = 0;
26
27
        $agent->addListener(function(RequestInterface $req) use (&$called) {
28
            $this->assertInstanceOf('CurlX\RequestInterface', $req);
29
            $called++;
30
        });
31
32
        $r = [];
33
        $agent->url = 'http://jsonplaceholder.typeicode.com/posts/1';
34
35
        for($i = 0; $i<20; $i++) {
36
            $r[] = $agent->newRequest();
37
        }
38
39
        $agent->execute();
40
41
        $this->assertEquals(20, $called);
42
        foreach($r as $req) {
43
            $this->assertNotNull($req->response);
44
        }
45
46
        var_dump($r[19]->response);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($r[19]->response); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
47
        var_dump($r[19]->url);
48
    }
49
}