Completed
Push — master ( 6985c5...4b67cd )
by Gabriel
09:30 queued 06:59
created

CountryCollectionTest::testOrderByCountryName()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 13
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
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