CountryCollectionTest::getCollection()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace GeoBase\Countries\Tests\Country;
4
5
use GeoBase\Countries\CountryRepository;
6
use PHPUnit\Framework\TestCase;
7
8
class CountryCollectionTest extends TestCase
9
{
10
    public function getCollection()
11
    {
12
        return (new CountryRepository())->findAll();
13
    }
14
15
    public function testOrderByCountryName()
16
    {
17
        $collection = $this->getCollection();
18
        $collection->orderByName('en');
19
        $this->assertGreaterThan(1, $collection->count());
20
        $previousName = null;
21
        foreach ($collection as $country) {
22
            $name = $country->getNames()->get('en')->getName();
23
            $result = strcasecmp($name, $previousName);
24
            $this->assertGreaterThan(0, $result);
25
            $previousName = $name;
26
        }
27
    }
28
}
29