Passed
Push — master ( 2cad2a...85c281 )
by Webysther
02:12
created

CircularArrayTest::testLooping()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 16
rs 9.4285
c 1
b 0
f 0
cc 3
eloc 9
nc 3
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Packagist Mirror.
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
    }
28
29
    public function testLooping()
30
    {
31
        $sample = array(1, 2, 3, 4);
32
        $circular = Circular::fromArray($sample);
33
        $counter = 0;
34
35
        foreach ($circular as $value) {
36
            $counter++;
37
38
            if($counter == 50){
39
                break;
40
            }
41
        }
42
43
        $this->assertSame(50, $counter);
44
    }
45
}
46