Completed
Push — master ( 92bd35...fb5c6c )
by Tom
04:10
created

ModuleListIteratorTest::iteration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 7

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 7
nc 1
nop 0
1
<?php
2
/*
3
 * this file is part of magerun
4
 *
5
 * @author Tom Klingenberg <https://github.com/ktomk>
6
 */
7
8
namespace N98\Magento\Api;
9
10
use Magento\Framework\Module\ModuleListInterface;
11
12
/**
13
 * @covers \N98\Magento\Api\ModuleListIterator
14
 */
15 View Code Duplication
class ModuleListIteratorTest extends TestCase
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
{
17
    /**
18
     * @return ModuleListIterator
19
     */
20
    private function getSubject()
21
    {
22
        /* @var $moduleList ModuleListInterface */
23
        $moduleList = $this->getObject(ModuleListInterface::class);
24
25
        $iterator = new ModuleListIterator($moduleList);
26
27
        return $iterator;
28
    }
29
30
    /**
31
     * @test
32
     */
33
    public function creation()
34
    {
35
        $iterator = $this->getSubject();
36
        $this->assertInstanceOf(ModuleListIterator::class, $iterator);
37
    }
38
39
    /**
40
     * @test
41
     */
42
    public function iteration()
43
    {
44
        $iterator = $this->getSubject();
45
        $array = iterator_to_array($iterator, false);
46
        $this->assertGreaterThan(0, count($array));
47
        $this->assertArrayHasKey(0, $array);
48
        $module = $array[0];
49
        $this->assertInstanceOf(ModuleInterface::class, $module);
50
    }
51
}
52