Total Complexity | 4 |
Total Lines | 47 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
8 | class MockWithExpectations |
||
9 | { |
||
10 | /** @var ExpectationsFactory */ |
||
11 | private $expectationsFactory; |
||
12 | |||
13 | /** @var MockFactory */ |
||
14 | private $mockFactory; |
||
15 | |||
16 | public function __construct( |
||
17 | ExpectationsFactory $expectationsFactory, |
||
18 | MockFactory $mockFactory) |
||
19 | { |
||
20 | $this->expectationsFactory = $expectationsFactory; |
||
21 | $this->mockFactory = $mockFactory; |
||
22 | } |
||
23 | |||
24 | public function createMockWithExpectations( |
||
25 | string $className, |
||
26 | array $expects = [], |
||
27 | array $constructorArgs = null) : PHPUnit_Framework_MockObject_MockObject |
||
28 | { |
||
29 | $expectations = $this->expectationsFactory->createExpectations($expects); |
||
30 | $expectedMethods = $expectations->getExpectedMethods(); |
||
31 | $mock = $this->mockFactory->newPartialMock($className, $expectedMethods, $constructorArgs); |
||
32 | $expectations->set($mock); |
||
33 | |||
34 | return $mock; |
||
35 | } |
||
36 | |||
37 | public function addExpectation( |
||
38 | PHPUnit_Framework_MockObject_MockObject $mock, |
||
39 | array $expectation) : PHPUnit_Framework_MockObject_MockObject |
||
40 | { |
||
41 | $this->addExpectations($mock, [$expectation]); |
||
42 | |||
43 | return $mock; |
||
44 | } |
||
45 | |||
46 | public function addExpectations( |
||
55 | } |
||
56 | } |
||
57 |