CircularArrayTest::testFromArray()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the PHP Snippets - Circular Array.
5
 *
6
 * For the full license information, please view the LICENSE.md
7
 * file that was distributed with this source code.
8
 */
9
10
namespace PHPSnippets\DataStructures\Tests;
11
12
use PHPUnit\Framework\TestCase;
13
use PHPSnippets\DataStructures\CircularArray as Circular;
14
15
/**
16
 * Circular Array tests.
17
 *
18
 * @author Webysther Nunes <[email protected]>
19
 */
20
class CircularArrayTest extends TestCase
21
{
22
    public function testFromArray()
23
    {
24
        $sample = array(1, 2, 3, 4);
25
        $circular = Circular::fromArray($sample);
26
        $this->assertSame($sample, $circular->toArray());
27
        $this->assertSame(count($sample), count($circular->toArray()));
28
    }
29
30
    public function testLooping()
31
    {
32
        $sample = array(1, 2, 3, 4);
33
        $circular = Circular::fromArray($sample);
34
        $counter = 0;
35
36
        foreach ($circular as $value) {
37
            $counter++;
38
39
            if($counter == 50){
40
                break;
41
            }
42
        }
43
44
        $this->assertSame(50, $counter);
45
    }
46
}
47