Failed Conditions
Branch master (01ba0d)
by Arnold
06:58 queued 01:45
created

LazyExecutionIteratorTrait   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Jasny\Tests;
6
7
use PHPUnit\Framework\MockObject\MockObject;
8
9
trait LazyExecutionIteratorTrait
10
{
11
    /**
12
     * Returns a test double for the specified class.
13
     *
14
     * @param string|string[] $originalClassName
15
     *
16
     * @throws Exception
17
     * @throws \InvalidArgumentException
18
     */
19
    abstract protected function createMock($originalClassName): MockObject;
20
21
    /**
22
     * Create an Iterator mock that fails when traversing.
23
     *
24
     * @return \Iterator|MockObject
25
     */
26
    protected function createLazyExecutionIterator()
27
    {
28
        $mock = $this->createMock(\Iterator::class);
29
30
        $mock->expects($this->any())->method('valid')->willReturn(true);
31
        $mock->expects($this->any())->method('rewind');
32
        $mock->expects($this->never())->method('key');
33
        $mock->expects($this->never())->method('current');
34
35
        return $mock;
36
    }
37
}