1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* XMPP Library |
4
|
|
|
* |
5
|
|
|
* Copyright (C) 2016, Some right reserved. |
6
|
|
|
* |
7
|
|
|
* @author Kacper "Kadet" Donat <[email protected]> |
8
|
|
|
* |
9
|
|
|
* Contact with author: |
10
|
|
|
* Xmpp: [email protected] |
11
|
|
|
* E-mail: [email protected] |
12
|
|
|
* |
13
|
|
|
* From Kadet with love. |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace Kadet\Xmpp\Tests; |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
use Kadet\Xmpp\Utils\PriorityCollection; |
20
|
|
|
|
21
|
|
|
class PriorityCollectionTest extends \PHPUnit_Framework_TestCase |
22
|
|
|
{ |
23
|
|
|
public function testPriorities() |
24
|
|
|
{ |
25
|
|
|
$collection = new PriorityCollection(); |
26
|
|
|
$collection->insert(0, 0); |
27
|
|
|
$collection->insert(1, 1); |
28
|
|
|
$collection->insert(-1, -1); |
29
|
|
|
|
30
|
|
|
$this->assertEquals([1, 0, -1], iterator_to_array($collection)); |
31
|
|
|
} |
32
|
|
|
|
33
|
|
|
public function testRemoval() |
34
|
|
|
{ |
35
|
|
|
$collection = new PriorityCollection(); |
36
|
|
|
$collection->insert(0, 0); |
37
|
|
|
$collection->insert(-1, -1); |
38
|
|
|
$collection->insert(-1, 1); |
39
|
|
|
$collection->remove(-1); |
40
|
|
|
|
41
|
|
|
$this->assertEquals([0], iterator_to_array($collection)); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
public function testCount() |
45
|
|
|
{ |
46
|
|
|
$collection = new PriorityCollection(); |
47
|
|
|
$this->assertEquals(0, count($collection)); |
48
|
|
|
$collection->insert(0, 0); |
49
|
|
|
$collection->insert(-1, -1); |
50
|
|
|
$this->assertEquals(2, count($collection)); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|