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

ModuleListVersionIteratorTest::getSubject()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 5

Duplication

Lines 12
Ratio 100 %

Importance

Changes 0
Metric Value
dl 12
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
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
use Magento\Framework\Module\ResourceInterface as ModuleResourceInterface;
12
13
/**
14
 * @covers \N98\Magento\Api\ModuleListVersionIterator
15
 */
16 View Code Duplication
class ModuleListVersionIteratorTest 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...
17
{
18
    /**
19
     * @return ModuleListVersionIterator
20
     */
21
    private function getSubject()
22
    {
23
        /* @var $moduleList ModuleListInterface */
24
        $moduleList = $this->getObject(ModuleListInterface::class);
25
26
        /* @var $resource ModuleResourceInterface */
27
        $resource = $this->getObject(ModuleResourceInterface::class);
28
29
        $iterator = new ModuleListVersionIterator($moduleList, $resource);
30
31
        return $iterator;
32
    }
33
34
    /**
35
     * @test
36
     */
37
    public function creation()
38
    {
39
        $iterator = $this->getSubject();
40
        $this->assertInstanceOf(ModuleListVersionIterator::class, $iterator);
41
    }
42
43
    /**
44
     * @test
45
     */
46
    public function iteration()
47
    {
48
        $iterator = $this->getSubject();
49
        $array = iterator_to_array($iterator, false);
50
        $this->assertGreaterThan(0, count($array));
51
        $this->assertArrayHasKey(0, $array);
52
        $module = $array[0];
53
        $this->assertInstanceOf(ModuleVersionInterface::class, $module);
54
    }
55
}
56