CountryCollectionTest   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 21
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCollection() 0 4 1
A testOrderByCountryName() 0 13 2
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