Passed
Branch master (98e19a)
by Petrică
02:49 queued 10s
created

ValuesCollectionTest::testCollection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 19
rs 9.4285
cc 1
eloc 14
nc 1
nop 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Petrica
5
 * Date: 3/30/2016
6
 * Time: 23:06
7
 */
8
namespace Petrica\StatsdSystem\Tests\Collection;
9
10
use Petrica\StatsdSystem\Collection\ValuesCollection;
11
12
class ValuesCollectionTest extends \PHPUnit_Framework_TestCase
13
{
14
    public function testCollection()
15
    {
16
        $collection = new ValuesCollection(array('test'));
17
        $collection->add('another', 1);
18
        $collection->offsetSet('offset', 10);
19
        $collection->offsetSet('missing', 5);
20
        $collection->offsetUnset('missing');
21
22
        $expected = array('test', 'another' => 1, 'offset' => 10);
23
24
        $iterator = new \ArrayIterator($expected);
25
26
        $this->assertEquals($expected, $collection->getValues());
27
        $this->assertEquals($iterator, $collection->getIterator());
28
        $this->assertEquals(3, $collection->count());
29
        $this->assertTrue($collection->offsetExists('another'));
30
        $this->assertFalse($collection->offsetExists('not_exist'));
31
        $this->assertEquals('test', $collection->offsetGet(0));
32
    }
33
}