1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Onoi\HttpRequest\Tests; |
4
|
|
|
|
5
|
|
|
use Onoi\HttpRequest\HttpRequestFactory; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* @covers \Onoi\HttpRequest\HttpRequestFactory |
9
|
|
|
* @group onoi-http-request |
10
|
|
|
* |
11
|
|
|
* @license GNU GPL v2+ |
12
|
|
|
* @since 1.0 |
13
|
|
|
* |
14
|
|
|
* @author mwjames |
15
|
|
|
*/ |
16
|
|
|
class HttpRequestFactoryTest extends \PHPUnit_Framework_TestCase { |
17
|
|
|
|
18
|
|
|
public function testCanConstruct() { |
19
|
|
|
|
20
|
|
|
$instance = new HttpRequestFactory(); |
21
|
|
|
|
22
|
|
|
$this->assertInstanceOf( |
23
|
|
|
'\Onoi\HttpRequest\HttpRequestFactory', |
24
|
|
|
$instance |
25
|
|
|
); |
26
|
|
|
} |
27
|
|
|
|
28
|
|
|
public function testCanConstructNullRequest() { |
29
|
|
|
|
30
|
|
|
$instance = new HttpRequestFactory(); |
31
|
|
|
|
32
|
|
|
$this->assertInstanceOf( |
33
|
|
|
'\Onoi\HttpRequest\NullRequest', |
34
|
|
|
$instance->newNullRequest() |
35
|
|
|
); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testCanConstructCurlRequest() { |
39
|
|
|
|
40
|
|
|
$instance = new HttpRequestFactory(); |
41
|
|
|
|
42
|
|
|
$this->assertInstanceOf( |
43
|
|
|
'\Onoi\HttpRequest\CurlRequest', |
44
|
|
|
$instance->newCurlRequest() |
45
|
|
|
); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testCanConstructCachedCurlRequest() { |
49
|
|
|
|
50
|
|
|
$cache = $this->getMockBuilder( '\Onoi\Cache\Cache' ) |
51
|
|
|
->disableOriginalConstructor() |
52
|
|
|
->getMockForAbstractClass(); |
53
|
|
|
|
54
|
|
|
$instance = new HttpRequestFactory( $cache ); |
55
|
|
|
|
56
|
|
|
$this->assertInstanceOf( |
57
|
|
|
'\Onoi\HttpRequest\CachedCurlRequest', |
58
|
|
|
$instance->newCachedCurlRequest() |
59
|
|
|
); |
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function testCanConstructMultiCurlRequest() { |
63
|
|
|
|
64
|
|
|
$instance = new HttpRequestFactory(); |
65
|
|
|
|
66
|
|
|
$this->assertInstanceOf( |
67
|
|
|
'\Onoi\HttpRequest\MultiCurlRequest', |
68
|
|
|
$instance->newMultiCurlRequest() |
69
|
|
|
); |
70
|
|
|
} |
71
|
|
|
|
72
|
|
|
public function testCanConstructSocketRequest() { |
73
|
|
|
|
74
|
|
|
$instance = new HttpRequestFactory(); |
75
|
|
|
|
76
|
|
|
$this->assertInstanceOf( |
77
|
|
|
'\Onoi\HttpRequest\SocketRequest', |
78
|
|
|
$instance->newSocketRequest() |
79
|
|
|
); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
} |
83
|
|
|
|