-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathClassInfoTraitTest.php
More file actions
52 lines (43 loc) · 1.69 KB
/
Copy pathClassInfoTraitTest.php
File metadata and controls
52 lines (43 loc) · 1.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
/*
* This file is part of the Silverback API Components Bundle Project
*
* (c) Daniel West <daniel@silverback.is>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Silverback\ApiComponentsBundle\Tests\Utility;
use PHPUnit\Framework\TestCase;
use Silverback\ApiComponentsBundle\Utility\ClassInfoTrait;
class ClassInfoTraitTest extends TestCase
{
private object $subject;
protected function setUp(): void
{
$this->subject = new class {
use ClassInfoTrait;
public function real(string $className): string
{
return $this->getRealClassName($className);
}
};
}
public function test_plain_class_name_is_returned_unchanged(): void
{
self::assertSame('App\\Entity\\Foo', $this->subject->real('App\\Entity\\Foo'));
}
public function test_doctrine_cg_proxy_marker_is_stripped(): void
{
// Kills LogicalAnd (line 41): with a '__CG__' marker present, `false === $positionCg` is false,
// so the early "return unchanged" must NOT fire — the real class name is extracted instead. The
// `||` mutant would return the proxy name unchanged.
self::assertSame('App\\Entity\\Foo', $this->subject->real('Proxies\\__CG__\\App\\Entity\\Foo'));
}
public function test_ocramius_pm_proxy_marker_is_stripped(): void
{
// Exercises the '__PM__' branch: the real class name sits between the marker and the trailing
// proxy-id segment.
self::assertSame('App\\Entity\\Foo', $this->subject->real('MyProxies\\__PM__\\App\\Entity\\Foo\\abc123'));
}
}