|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* This file is part of the beebot package. |
|
4
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
5
|
|
|
* file that was distributed with this source code. |
|
6
|
|
|
* |
|
7
|
|
|
* @copyright Bee4 2015 |
|
8
|
|
|
* @author Stephane HULARD <[email protected]> |
|
9
|
|
|
* @package Bee4\Test\Transport\Message |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace Bee4\Test\Transport\Message; |
|
13
|
|
|
|
|
14
|
|
|
use Bee4\Transport\Message\Request\RequestFactory; |
|
15
|
|
|
use Bee4\Transport\Url; |
|
16
|
|
|
|
|
17
|
|
|
/** |
|
18
|
|
|
* RequestFactory unit test definition |
|
19
|
|
|
* @package Bee4\Test\Transport\Message |
|
20
|
|
|
*/ |
|
21
|
|
|
class RequestFactoryTest extends \PHPUnit_Framework_TestCase |
|
22
|
|
|
{ |
|
23
|
|
|
public function testBuild() |
|
24
|
|
|
{ |
|
25
|
|
|
$object = new RequestFactory(); |
|
26
|
|
|
|
|
27
|
|
|
$get = $object->build('GET', new Url('http://www.bee4.fr'), ['Content-Type' => 'text/html']); |
|
28
|
|
|
$this->assertInstanceOf('\Bee4\Transport\Message\Request\Http\Get', $get); |
|
29
|
|
|
$this->assertEquals('text/html', $get->getHeader('Content-Type')); |
|
30
|
|
|
$post = $object->build('POST', new Url('http://www.bee4.fr'), ['Content-Length' => 128]); |
|
31
|
|
|
$this->assertInstanceOf('\Bee4\Transport\Message\Request\Http\Post', $post); |
|
32
|
|
|
$this->assertEquals(128, $post->getHeader('Content-Length')); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @expectedException \InvalidArgumentException |
|
37
|
|
|
*/ |
|
38
|
|
|
public function testInvalidRequestBuild() |
|
39
|
|
|
{ |
|
40
|
|
|
$object = new RequestFactory(); |
|
41
|
|
|
$object->build('UNKNOWN', new Url('http://www.bee4.fr'), []); |
|
42
|
|
|
} |
|
43
|
|
|
} |
|
44
|
|
|
|