Completed
Push — master ( 1debd7...be65da )
by Jeroen
12:58 queued 12s
created

SitemapUrlTest::priorityDataProvider()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.9666
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Kunstmaan\SitemapBundle\Tests\unit\Model;
4
5
use Kunstmaan\SitemapBundle\Model\SitemapUrl;
6
use PHPUnit\Framework\TestCase;
7
8
class SitemapUrlTest extends TestCase
9
{
10
    /**
11
     * @dataProvider priorityDataProvider
12
     */
13
    public function testPriorityValues(float $priority, bool $expectException)
14
    {
15
        if ($expectException) {
16
            $this->expectException(\InvalidArgumentException::class);
17
            $this->expectExceptionMessage(sprintf('A sitemap url priority can\'t be higher than 1 or below 0. Value given "%s"', $priority));
18
        }
19
20
        $obj = new SitemapUrl('example-url', new \DateTimeImmutable(), $priority);
21
22
        if (!$expectException) {
23
            $this->assertInstanceOf(SitemapUrl::class, $obj);
24
            $this->assertSame($priority, $obj->getPriority());
25
        }
26
    }
27
28 View Code Duplication
    public function priorityDataProvider()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
29
    {
30
        return [
31
            [0.0, false],
32
            [-1.0, true],
33
            [1.0, false],
34
            [1.2, true],
35
        ];
36
    }
37
}
38