Completed
Push — master ( f62226...8b6b73 )
by Stéphane
10s
created

AbstractRequestTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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\Request
10
 */
11
12
namespace Bee4\Test\Transport\Message\Request;
13
14
use Bee4\PHPUnit\HttpClientTestCase;
15
use Bee4\Transport\Configuration\Configuration;
16
use Bee4\Transport\Client;
17
use Bee4\Transport\Url;
18
19
/**
20
 * AbstractRequest test definition
21
 * @package Bee4\Test\Transport\Message\Request
22
 */
23
class AbstractRequestTest extends HttpClientTestCase
24
{
25
    /**
26
     * @var Url
27
     */
28
    protected $url;
29
30
    /**
31
     * Build an Url object which represent BaseUrl
32
     */
33
    public function setUp()
34
    {
35
        $this->url = new Url(self::getBaseUrl());
36
    }
37
38
    /**
39
     * Check that constructor works well
40
     */
41
    public function testConstructor()
42
    {
43
        $headers = ['content-type' => 'text/html'];
44
45
        $mock = $this->getMockForAbstractClass(
46
            '\Bee4\Transport\Message\Request\AbstractRequest',
47
            [$this->url, $headers, new Configuration]
48
        );
49
50
        $this->assertEquals($headers, $mock->getHeaders());
51
        $this->assertEquals(
52
            self::getBaseUrl(),
53
            (string)$mock->getUrl()
54
        );
55
    }
56
57
    /**
58
     * @expectedException \Bee4\Transport\Exception\RuntimeException
59
     */
60
    public function testInvalidClient()
61
    {
62
        $mock = $this->getMockForAbstractClass('\Bee4\Transport\Message\Request\AbstractRequest', [$this->url]);
63
        $mock->send();
64
    }
65
66
    /**
67
     * Check that request send method return a valid response object
68
     */
69
    public function testSend()
70
    {
71
        $mock = $this->getMockForAbstractClass('\Bee4\Transport\Message\Request\AbstractRequest', [$this->url]);
72
        $mock->setClient(new Client());
73
        $response = $mock->send();
74
75
        $this->assertInstanceOf('\Bee4\Transport\Message\Response', $response);
76
    }
77
}
78