Passed
Branch master (e8fd46)
by Alexey
03:15
created

RequestFactoryTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 52
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 5
1
<?php
2
3
use PHPUnit\Framework\TestCase;
4
use Zend\Diactoros\Uri;
5
6
/**
7
 * Class RequestFactoryTest
8
 */
9
class RequestFactoryTest extends TestCase
10
{
11
    /**
12
     * @var \Venta\Http\Factory\RequestFactory
13
     */
14
    protected $factory;
15
16
    public function setUp()
17
    {
18
        $this->factory = new \Venta\Http\Factory\RequestFactory;
19
    }
20
21
    /**
22
     * @test
23
     */
24
    public function canCreateRequestWithUriInstance()
25
    {
26
        $uri = new Uri('/foo.bar');
27
        $request = $this->factory->createServerRequest('GET', $uri);
28
        $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request);
29
        $this->assertSame('GET', $request->getMethod());
30
        $this->assertSame($uri, $request->getUri());
31
    }
32
33
    /**
34
     * @test
35
     */
36
    public function canCreateServerRequestFromGlobals()
37
    {
38
        $request = $this->factory->createServerRequestFromGlobals();
39
        $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request);
40
    }
41
42
    /**
43
     * @test
44
     */
45
    public function canCreateServerRequestWithParams()
46
    {
47
        $request = $this->factory->createServerRequest('GET', '/foo.bar');
48
        $this->assertInstanceOf(\Venta\Contracts\Http\Request::class, $request);
49
        $this->assertSame('GET', $request->getMethod());
50
        $this->assertSame('/foo.bar', $request->getUri()->__toString());
51
    }
52
53
    /**
54
     * @test
55
     */
56
    public function implementsRequestFactoryContract()
57
    {
58
        $this->assertInstanceOf(\Venta\Contracts\Http\RequestFactory::class, new \Venta\Http\Factory\RequestFactory);
59
    }
60
}