HttpTransactionTest::testSymfonyRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
rs 9.4285
c 1
b 0
f 0
cc 1
eloc 5
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
            ->setId(1)
22
            ->setRequest($request)
23
            ->setResponse($response)
24
            ->setIp('127.0.0.1')
25
        ;
26
27
        $this->assertSame(1, $httpTransaction->getId());
28
        $this->assertSame($request, $httpTransaction->getRequest());
29
        $this->assertSame($response, $httpTransaction->getResponse());
30
        $this->assertSame('127.0.0.1', $httpTransaction->getIp());
31
    }
32
33
    public function testSymfonyRequest()
34
    {
35
        $httpTransaction = $this->getHttpTransaction();
36
37
        $request = Request::createFromGlobals();
38
39
        $httpTransaction->setRequest($request);
40
41
        $this->assertInternalType('string', $httpTransaction->getRequest());
42
    }
43
44
    public function testSymfonyRequestPost()
45
    {
46
        $httpTransaction = $this->getHttpTransaction();
47
48
        $request = Request::create('/test', 'POST', ['key' => 'vaæ']);
49
50
        $httpTransaction->setRequest($request);
51
52
        $this->assertInternalType('string', $httpTransaction->getRequest());
53
    }
54
55
    /**
56
     * @return HttpTransaction
57
     */
58
    public function getHttpTransaction()
59
    {
60
        return $this->getMockForAbstractClass(HttpTransaction::class);
61
    }
62
}
63