1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace ProxyManagerTest\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator; |
6
|
|
|
|
7
|
|
|
use Laminas\Code\Generator\PropertyGenerator; |
8
|
|
|
use PHPUnit\Framework\MockObject\MockObject; |
9
|
|
|
use PHPUnit\Framework\TestCase; |
10
|
|
|
use ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset; |
11
|
|
|
use ProxyManager\ProxyGenerator\PropertyGenerator\PublicPropertiesMap; |
12
|
|
|
use ProxyManagerTestAsset\EmptyClass; |
13
|
|
|
use ReflectionClass; |
14
|
|
|
use function strpos; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Tests for {@see \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset} |
18
|
|
|
* |
19
|
|
|
* @group Coverage |
20
|
|
|
*/ |
21
|
|
|
final class MagicIssetTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
/** |
24
|
|
|
* @covers \ProxyManager\ProxyGenerator\AccessInterceptorValueHolder\MethodGenerator\MagicIsset::__construct |
25
|
|
|
*/ |
26
|
|
|
public function testBodyStructure() : void |
27
|
|
|
{ |
28
|
|
|
$reflection = new ReflectionClass(EmptyClass::class); |
29
|
|
|
$valueHolder = $this->createMock(PropertyGenerator::class); |
|
|
|
|
30
|
|
|
$prefixInterceptors = $this->createMock(PropertyGenerator::class); |
|
|
|
|
31
|
|
|
$suffixInterceptors = $this->createMock(PropertyGenerator::class); |
|
|
|
|
32
|
|
|
$publicProperties = $this->createMock(PublicPropertiesMap::class); |
|
|
|
|
33
|
|
|
|
34
|
|
|
$valueHolder->method('getName')->willReturn('bar'); |
|
|
|
|
35
|
|
|
$prefixInterceptors->method('getName')->willReturn('pre'); |
|
|
|
|
36
|
|
|
$suffixInterceptors->method('getName')->willReturn('post'); |
|
|
|
|
37
|
|
|
$publicProperties->method('isEmpty')->willReturn(false); |
|
|
|
|
38
|
|
|
|
39
|
|
|
$magicIsset = new MagicIsset( |
40
|
|
|
$reflection, |
41
|
|
|
$valueHolder, |
|
|
|
|
42
|
|
|
$prefixInterceptors, |
|
|
|
|
43
|
|
|
$suffixInterceptors, |
|
|
|
|
44
|
|
|
$publicProperties |
|
|
|
|
45
|
|
|
); |
46
|
|
|
|
47
|
|
|
self::assertSame('__isset', $magicIsset->getName()); |
|
|
|
|
48
|
|
|
self::assertCount(1, $magicIsset->getParameters()); |
|
|
|
|
49
|
|
|
self::assertGreaterThan(0, strpos($magicIsset->getBody(), '$returnValue = isset($this->bar->$name);')); |
|
|
|
|
50
|
|
|
} |
51
|
|
|
} |
52
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.