Completed
Pull Request — master (#396)
by
unknown
02:51
created

InitializeProxyTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 2
dl 0
loc 26
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ProxyManagerTest\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator;
6
7
use PHPUnit\Framework\TestCase;
8
use ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy;
9
use Zend\Code\Generator\PropertyGenerator;
10
11
/**
12
 * Tests for {@see \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy}
13
 *
14
 * @author Marco Pivetta <[email protected]>
15
 * @license MIT
16
 *
17
 * @group Coverage
18
 */
19
class InitializeProxyTest extends TestCase
20
{
21
    /**
22
     * @covers \ProxyManager\ProxyGenerator\LazyLoadingValueHolder\MethodGenerator\InitializeProxy::__construct
23
     */
24
    public function testBodyStructure() : void
25
    {
26
        /* @var $initializer PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject */
27
        $initializer = $this->createMock(PropertyGenerator::class);
28
        /* @var $valueHolder PropertyGenerator|\PHPUnit_Framework_MockObject_MockObject */
29
        $valueHolder = $this->createMock(PropertyGenerator::class);
30
31
        $initializer->expects(self::any())->method('getName')->will(self::returnValue('foo'));
32
        $valueHolder->expects(self::any())->method('getName')->will(self::returnValue('bar'));
33
34
        $initializeProxy = new InitializeProxy($initializer, $valueHolder);
35
36
        self::assertSame('initializeProxy', $initializeProxy->getName());
37
        self::assertCount(0, $initializeProxy->getParameters());
38
        self::assertSame(
39
            'return $this->foo && ($this->foo->__invoke($bar, $this, \'initializeProxy\', array(), $this->foo) || 1)'
40
            . ' && $this->bar = $bar;'
41
            $initializeProxy->getBody()
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_VARIABLE, expecting ',' or ')'
Loading history...
42
        );
43
        self::assertStringMatchesFormat('%A : bool%A', $initializeProxy->generate(), 'Return type hint is boolean');
44
    }
45
}
46