PriorityQueueTest::testCompare()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 7
rs 10
cc 1
nc 1
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ArpTest\EventDispatcher\Listener;
6
7
use Arp\EventDispatcher\Listener\PriorityQueue;
8
use PHPUnit\Framework\TestCase;
9
10
/**
11
 * @covers \Arp\EventDispatcher\Listener\PriorityQueue
12
 */
13
final class PriorityQueueTest extends TestCase
14
{
15
    public function testExtendsSplPriorityQueue(): void
16
    {
17
        $priorityQueue = new PriorityQueue();
18
19
        $this->assertInstanceOf(\SplPriorityQueue::class, $priorityQueue);
20
    }
21
22
    /**
23
     * @dataProvider getCompareData
24
     */
25
    public function testCompare(mixed $priority1, mixed $priority2): void
26
    {
27
        $priorityQueue = new PriorityQueue();
28
29
        $this->assertSame(
30
            ($priority1 <=> $priority2),
31
            $priorityQueue->compare($priority1, $priority2)
32
        );
33
    }
34
35
    /**
36
     * @return array<mixed>
37
     */
38
    public function getCompareData(): array
39
    {
40
        return [
41
            [1, 1],
42
            [100, 200],
43
            [300, 1],
44
            [2345, 999],
45
            [1, 1],
46
            [1000, 1000],
47
            [
48
                [1, 100],
49
                [1, 100],
50
            ],
51
            [
52
                [1000, 12398612],
53
                [1000, 92398612],
54
            ],
55
            [
56
                [1239840, 100],
57
                [10354561, 1123123],
58
            ],
59
        ];
60
    }
61
}
62