Passed
Push — master ( ee8fa9...afffd0 )
by Tim
03:17
created

IpLocationTest::testInvalidRepsonse()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 7
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LD\LanguageDetection\Tests\Unit\Service;
6
7
use LD\LanguageDetection\Service\IpLocation;
8
use LD\LanguageDetection\Tests\Unit\AbstractTest;
9
use TYPO3\CMS\Core\Http\RequestFactory;
10
11
/**
12
 * @internal
13
 * @coversNothing
14
 */
15
class IpLocationTest extends AbstractTest
16
{
17
    /**
18
     * @covers \LD\LanguageDetection\Service\IpLocation
19
     */
20
    public function testGetLocationForValidIp(): void
21
    {
22
        $locationService = new IpLocation(new RequestFactory());
23
        $result = $locationService->getCountryCode('8.8.8.8');
24
25
        self::assertEquals('US', $result);
26
    }
27
28
    /**
29
     * @covers \LD\LanguageDetection\Service\IpLocation
30
     */
31
    public function testEmptyIpDirectNull(): void
32
    {
33
        $locationService = new IpLocation(new RequestFactory());
34
35
        self::assertNull($locationService->getCountryCode(''));
0 ignored issues
show
Bug introduced by
Are you sure the usage of $locationService->getCountryCode('') targeting LD\LanguageDetection\Ser...ation::getCountryCode() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
36
    }
37
38
    /**
39
     * @covers \LD\LanguageDetection\Service\IpLocation
40
     */
41
    public function testGetLocationForInvalidIp(): void
42
    {
43
        $locationService = new IpLocation(new RequestFactory());
44
        self::assertNull($locationService->getCountryCode('0.0.0.0'));
45
    }
46
}
47