Skip to content

Commit 687bd41

Browse files
committed
#632 #645 #646 moved PublicScopeSimulator functional test to tests/PRoxyManagerTest/Functional (and removed coverage)
1 parent 04ab867 commit 687bd41

File tree

2 files changed

+49
-31
lines changed

2 files changed

+49
-31
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace ProxyManagerTest\ProxyGenerator\Functional;
6+
7+
use PHPUnit\Framework\TestCase;
8+
use ProxyManager\ProxyGenerator\Util\PublicScopeSimulator;
9+
use ProxyManagerTestAsset\ClassWithMixedProperties;
10+
11+
use function sprintf;
12+
13+
/**
14+
* @covers \ProxyManager\ProxyGenerator\Util\PublicScopeSimulator
15+
* @coversNothing
16+
*/
17+
final class PublicScopeSimulatorFunctionalTest extends TestCase
18+
{
19+
/**
20+
* @group #632
21+
* @group #645
22+
* @group #646
23+
*/
24+
public function testAccessingUndefinedPropertiesDoesNotLeadToInvalidByRefAccess(): void
25+
{
26+
/** @psalm-var ClassWithMixedProperties $sut */
27+
$sut = eval(sprintf(
28+
<<<'PHP'
29+
return new class() extends %s {
30+
public function doGet($prop) : string { %s }
31+
public function doSet($prop, $val) : string { %s }
32+
public function doIsset($prop) : bool { %s }
33+
public function doUnset($prop) : void { %s }
34+
};
35+
PHP
36+
,
37+
ClassWithMixedProperties::class,
38+
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_GET, 'prop'),
39+
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'prop', 'val'),
40+
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_ISSET, 'prop'),
41+
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_UNSET, 'prop')
42+
));
43+
44+
self::assertSame('publicProperty0', $sut->doGet('publicProperty0'));
45+
self::assertSame('bar', $sut->doSet('publicProperty0', 'bar'));
46+
self::assertTrue($sut->doIsset('publicProperty0'));
47+
self::assertNull($sut->doUnset('publicProperty0'));
48+
}
49+
}

tests/ProxyManagerTest/ProxyGenerator/Util/PublicScopeSimulatorTest.php

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -299,35 +299,4 @@ public function testWillNotAttemptToGetParentClassWhenReflectionClassIsGivenUpfr
299299
)
300300
);
301301
}
302-
303-
/**
304-
* @group #632
305-
* @group #645
306-
* @group #646
307-
*/
308-
public function testFunctional(): void
309-
{
310-
/** @psalm-var ClassWithMixedProperties $sut */
311-
$sut = eval(
312-
sprintf(
313-
'return new class() extends %s
314-
{
315-
public function doGet($prop) { %s }
316-
public function doSet($prop, $val) { %s }
317-
public function doIsset($prop) { %s }
318-
public function doUnset($prop) { %s }
319-
};',
320-
ClassWithMixedProperties::class,
321-
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_GET, 'prop'),
322-
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_SET, 'prop', 'val'),
323-
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_ISSET, 'prop'),
324-
PublicScopeSimulator::getPublicAccessSimulationCode(PublicScopeSimulator::OPERATION_UNSET, 'prop')
325-
)
326-
);
327-
328-
$this->assertSame('publicProperty0', $sut->doGet('publicProperty0'));
329-
$this->assertSame('bar', $sut->doSet('publicProperty0', 'bar'));
330-
$this->assertTrue($sut->doIsset('publicProperty0'));
331-
$this->assertNull($sut->doUnset('publicProperty0'));
332-
}
333302
}

0 commit comments

Comments
 (0)