Completed
Push — master ( 0ed61c...03ecff )
by Joachim
15:52
created

HttpTransactionTest::getHttpTransaction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Tests\Entity;
4
5
use Loevgaard\DandomainAltapayBundle\Entity\HttpTransaction;
6
use PHPUnit\Framework\TestCase;
7
use Psr\Http\Message\RequestInterface;
8
use Psr\Http\Message\ResponseInterface;
9
use Symfony\Component\HttpFoundation\Request;
10
11
class HttpTransactionTest extends TestCase
12
{
13
    public function testGettersSetters()
14
    {
15
        $httpTransaction = $this->getHttpTransaction();
16
17
        $request = $this->getMockClass(RequestInterface::class);
18
        $response = $this->getMockClass(ResponseInterface::class);
19
20
        $httpTransaction
21
            ->setRequest($request)
22
            ->setResponse($response)
23
            ->setIp('127.0.0.1')
24
        ;
25
26
        $this->assertSame($request, $httpTransaction->getRequest());
27
        $this->assertSame($response, $httpTransaction->getResponse());
28
        $this->assertSame('127.0.0.1', $httpTransaction->getIp());
29
    }
30
31
    public function testSymfonyRequest()
32
    {
33
        $httpTransaction = $this->getHttpTransaction();
34
35
        $request = Request::createFromGlobals();
36
37
        $httpTransaction->setRequest($request);
38
39
        $this->assertInternalType('string', $httpTransaction->getRequest());
40
    }
41
42
    public function testSymfonyRequestPost()
43
    {
44
        $httpTransaction = $this->getHttpTransaction();
45
46
        $request = Request::create('/test', 'POST', ['key' => 'vaæ']);
47
48
        $httpTransaction->setRequest($request);
49
50
        $this->assertInternalType('string', $httpTransaction->getRequest());
51
    }
52
53
    /**
54
     * @return HttpTransaction
55
     */
56
    public function getHttpTransaction()
57
    {
58
        return $this->getMockForAbstractClass(HttpTransaction::class);
59
    }
60
}
61