8000 [DoctrineBridge]  change test to use a real ObjectManager by xabbuh · Pull Request #57489 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DoctrineBridge]  change test to use a real ObjectManager #57489

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
change test to use a real ObjectManager
  • Loading branch information
xabbuh committed Jun 22, 2024
commit 0fc7293c30ff456e81f0067cafcc52ac8e070d2e
26 changes: 17 additions & 9 deletions src/Symfony/Bridge/Doctrine/Tests/LegacyManagerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@

namespace Symfony\Bridge\Doctrine\Tests;

use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\TestCase;
use ProxyManager\Proxy\LazyLoadingInterface;
use ProxyManager\Proxy\ValueHolderInterface;
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Bridge\ProxyManager\Tests\LazyProxy\Dumper\PhpDumperTest;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
Expand All @@ -28,9 +29,16 @@ class LegacyManagerRegistryTest extends TestCase
{
public static function setUpBeforeClass(): void
{
if (!class_exists(\LazyServiceProjectServiceContainer::class, false)) {
eval('?>'.PhpDumperTest::dumpLazyServiceProjectServiceContainer());
}
$container = new ContainerBuilder();

$container->register('foo', DummyManager::class)->setPublic(true);
$container->getDefinition('foo')->setLazy(true)->addTag('proxy', ['interface' => ObjectManager::class]);
$container->compile();

$dumper = new PhpDumper($container);
$dumper->setProxyDumper(new ProxyDumper());

eval('?>'.$dumper->dump(['class' => 'LazyServiceProjectServiceContainer']));
}

public function testResetService()
Expand All @@ -47,8 +55,8 @@ public function testResetService()
$registry->resetManager();

$this->assertSame($foo, $container->get('foo'));
$this->assertInstanceOf(\stdClass::class, $foo);
$this->assertFalse(property_exists($foo, 'bar'));
$this->assertInstanceOf(ObjectManager::class, $foo);
$this->assertFalse(isset($foo->bar));
}

/**
Expand Down Expand Up @@ -80,7 +88,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()

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

self::assertInstanceOf(\stdClass::class, $service);
self::assertInstanceOf(DummyManager::class, $service);
self::assertInstanceOf(LazyLoadingInterface::class, $service);
self::assertInstanceOf(ValueHolderInterface::class, $service);
self::assertFalse($service->isProxyInitialized());
Expand All @@ -94,7 +102,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
$service->initializeProxy();

$wrappedValue = $service->getWrappedValueHolderValue();
self::assertInstanceOf(\stdClass::class, $wrappedValue);
self::assertInstanceOf(DummyManager::class, $wrappedValue);
self::assertNotInstanceOf(LazyLoadingInterface::class, $wrappedValue);
self::assertNotInstanceOf(ValueHolderInterface::class, $wrappedValue);
}
8000 Expand All @@ -107,7 +115,7 @@ private function dumpLazyServiceProjectAsFilesServiceContainer()

$container = new ContainerBuilder();

$container->register('foo', \stdClass::class)
$container->register('foo', DummyManager::class)
->setPublic(true)
->setLazy(true);
$container->compile();
Expand Down
4 changes: 0 additions & 4 deletions src/Symfony/Bridge/Doctrine/Tests/ManagerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,7 @@

use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\TestCase;
use ProxyManager\Proxy\LazyLoadingInterface;
use ProxyManager\Proxy\ValueHolderInterface;
use Symfony\Bridge\Doctrine\ManagerRegistry;
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
use Symfony\Bridge\ProxyManager\LazyProxy\PhpDumper\ProxyDumper;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
Expand Down
Loading
0