Passed
Push — master ( 8f669d...12a285 )
by Dmitrii
01:40 queued 10s
created

IpResolverTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testRequest() 0 6 1
A testEmptyRequest() 0 6 1
1
<?php declare(strict_types=1);
2
3
namespace Karser\Recaptcha3Bundle\Tests\Services;
4
5
use Karser\Recaptcha3Bundle\Services\IpResolver;
6
use PHPUnit\Framework\TestCase;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\RequestStack;
9
10
class IpResolverTest extends TestCase
11
{
12
    public function testEmptyRequest()
13
    {
14
        $stack = new RequestStack();
15
        $stack->push(new Request());
16
        $resolver = new IpResolver($stack);
17
        self::assertNull($resolver->resolveIp());
18
    }
19
20
    public function testRequest()
21
    {
22
        $stack = new RequestStack();
23
        $stack->push(new Request([], [], [], [], [], ['REMOTE_ADDR' => '0.0.0.0']));
24
        $resolver = new IpResolver($stack);
25
        self::assertSame('0.0.0.0', $resolver->resolveIp());
26
    }
27
}
28