Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 79b03db

Browse filesBrowse files
committed
[DoctrineBridge] Test reset with a true manager
1 parent 53a3024 commit 79b03db
Copy full SHA for 79b03db

File tree

Expand file treeCollapse file tree

2 files changed

+85
-9
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+85
-9
lines changed
+69Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
<?php
2+
3+
namespace Symfony\Bridge\Doctrine\Tests\Fixtures;
4+
5+
use Doctrine\Persistence\Mapping\ClassMetadata;
6+
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
7+
use Doctrine\Persistence\ObjectManager;
8+
use Doctrine\Persistence\ObjectRepository;
9+
10+
class DummyManager implements ObjectManager
11+
{
12+
public $bar;
13+
14+
public function find($className, $id): ?object
15+
{
16+
}
17+
18+
public function persist($object): void
19+
{
20+
}
21+
22+
public function remove($object): void
23+
{
24+
}
25+
26+
public function merge($object)
27+
{
28+
}
29+
30+
public function clear($objectName = null): void
31+
{
32+
}
33+
34+
public function detach($object): void
35+
{
36+
}
37+
38+
public function refresh($object): void
39+
{
40+
}
41+
42+
public function flush(): void
43+
{
44+
}
45+
46+
public function getRepository($className): ObjectRepository
47+
{
48+
}
49+
50+
public function getClassMetadata($className): ClassMetadata
51+
{
52+
}
53+
54+
public function getMetadataFactory(): ClassMetadataFactory
55+
{
56+
}
57+
58+
public function initializeObject($obj): void
59+
{
60+
}
61+
62+
public function contains($object): bool
63+
{
64+
}
65+
66+
public function isUninitializedObject($value): bool
67+
{
68+
}
69+
}

‎src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php

Copy file name to clipboardExpand all lines: src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php
+16-9Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
use ProxyManager\Proxy\LazyLoadingInterface;
1616
use ProxyManager\Proxy\ValueHolderInterface;
1717
use Symfony\Bridge\Doctrine\ManagerRegistry;
18+
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
1819
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
19-
use Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper\PhpDumperTest;
2020
use Symfony\Component\DependencyInjection\ContainerBuilder;
2121
use Symfony\Component\DependencyInjection\ContainerInterface;
2222
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
@@ -26,13 +26,20 @@ class ManagerRegistryTest extends TestCase
2626
{
2727
public static function setUpBeforeClass(): void
2828
{
29-
$test = new PhpDumperTest();
30-
$test->testDumpContainerWithProxyServiceWillShareProxies();
29+
$container = new ContainerBuilder();
30+
31+
$container->register('foo', DummyManager::class)->setPublic(true);
32+
$container->getDefinition('foo')->setLazy(true);
33+
$container->compile();
34+
35+
$dumper = new PhpDumper($container);
36+
$dumper->setProxyDumper(new ProxyDumper());
37+
eval('?>'.$dumper->dump(['class' => 'LazyServiceDoctrineBridgeContainer']));
3138
}
3239

3340
public function testResetService()
3441
{
35-
$container = new \LazyServiceProjectServiceContainer();
42+
$container = new \LazyServiceDoctrineBridgeContainer();
3643

3744
$registry = new TestManagerRegistry('name', [], ['defaultManager' => 'foo'], 'defaultConnection', 'defaultManager', 'proxyInterfaceName');
3845
$registry->setTestContainer($container);
@@ -44,8 +51,8 @@ public function testResetService()
4451
$registry->resetManager();
4552

4653
$this->assertSame($foo, $container->get('foo'));
47-
$this->assertInstanceOf(\stdClass::class, $foo);
48-
$this->assertFalse(property_exists($foo, 'bar'));
54+
$this->assertInstanceOf(DummyManager::class, $foo);
55+
$this->assertFalse(isset($foo->bar));
4956
}
5057

5158
/**
@@ -77,7 +84,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
7784

7885
$service = $container->get('foo');
7986

80-
self::assertInstanceOf(\stdClass::class, $service);
87+
self::assertInstanceOf(DummyManager::class, $service);
8188
self::assertInstanceOf(LazyLoadingInterface::class, $service);
8289
self::assertInstanceOf(ValueHolderInterface::class, $service);
8390
self::assertFalse($service->isProxyInitialized());
@@ -91,7 +98,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
9198
$service->initializeProxy();
9299

93100
$wrappedValue = $service->getWrappedValueHolderValue();
94-
self::assertInstanceOf(\stdClass::class, $wrappedValue);
101+
self::assertInstanceOf(DummyManager::class, $wrappedValue);
95102
self::assertNotInstanceOf(LazyLoadingInterface::class, $wrappedValue);
96103
self::assertNotInstanceOf(ValueHolderInterface::class, $wrappedValue);
97104
}
@@ -104,7 +111,7 @@ private function dumpLazyServiceProjectAsFilesServiceContainer()
104111

105112
$container = new ContainerBuilder();
106113

107-
$container->register('foo', \stdClass::class)
114+
$container->register('foo', DummyManager::class)
108115
->setPublic(true)
109116
->setLazy(true);
110117
$container->compile();

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.