Skip to content

Commit

Permalink
Merge branch '7.0' into 7.1
Browse files Browse the repository at this point in the history
* 7.0: (29 commits)
  fix tests
  add missing method
  fix merge
  fix test
  fix merge
  fix test
  change test to use a real ObjectManager
  [Mailer] Document the usage of custom headers in Infobip bridge
  [SecurityBundle] Add `provider` XML attribute to the authenticators it’s missing from
  [DoctrineBridge] Test reset with a true manager
  Sync php-cs-fixer config file with 7.2
  [HttpClient] Fix parsing SSE
  [Notifier] Fix thread key in GoogleChat bridge
  [HttpKernel][Security] Fix accessing session for stateless request
  [Serializer] Fix `ObjectNormalizer` with property path
  test handling of special "value" constraint option
  [PhpUnitBridge] Add missing import
  [FrameworkBundle] Fix setting default context for certain normalizers
  [57251] Missing translations for Romanian (ro)
  [ErrorHandler] Fix rendered exception code highlighting on PHP 8.3
  ...
  • Loading branch information
xabbuh committed Jun 25, 2024
2 parents b7ae744 + 90ded9f commit 9cbab67
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 8 deletions.
69 changes: 69 additions & 0 deletions Tests/Fixtures/DummyManager.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<?php

namespace Symfony\Bridge\Doctrine\Tests\Fixtures;

use Doctrine\Persistence\Mapping\ClassMetadata;
use Doctrine\Persistence\Mapping\ClassMetadataFactory;
use Doctrine\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectRepository;

class DummyManager implements ObjectManager
{
public $bar;

public function find($className, $id): ?object
{
}

public function persist($object): void
{
}

public function remove($object): void
{
}

public function merge($object)
{
}

public function clear($objectName = null): void
{
}

public function detach($object): void
{
}

public function refresh($object): void
{
}

public function flush(): void
{
}

public function getRepository($className): ObjectRepository
{
}

public function getClassMetadata($className): ClassMetadata
{
}

public function getMetadataFactory(): ClassMetadataFactory
{
}

public function initializeObject($obj): void
{
}

public function contains($object): bool
{
}

public function isUninitializedObject($value): bool
{
}
}
18 changes: 10 additions & 8 deletions Tests/ManagerRegistryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

namespace Symfony\Bridge\Doctrine\Tests;

use Doctrine\Persistence\ObjectManager;
use PHPUnit\Framework\TestCase;
use Symfony\Bridge\Doctrine\Tests\Fixtures\DummyManager;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\Dumper\PhpDumper;
Expand All @@ -24,8 +26,8 @@ public static function setUpBeforeClass(): void
{
$container = new ContainerBuilder();

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

$dumper = new PhpDumper($container);
Expand All @@ -46,8 +48,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 @@ -79,7 +81,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()

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

self::assertInstanceOf(\stdClass::class, $service);
self::assertInstanceOf(ObjectManager::class, $service);
self::assertInstanceOf(LazyObjectInterface::class, $service);
self::assertFalse($service->isLazyObjectInitialized());

Expand All @@ -92,7 +94,7 @@ public function testResetServiceWillNotNestFurtherLazyServicesWithinEachOther()
$service->initializeLazyObject();

$wrappedValue = $service->initializeLazyObject();
self::assertInstanceOf(\stdClass::class, $wrappedValue);
self::assertInstanceOf(DummyManager::class, $wrappedValue);
self::assertNotInstanceOf(LazyObjectInterface::class, $wrappedValue);
}

Expand All @@ -104,10 +106,10 @@ private function dumpLazyServiceDoctrineBridgeContainerAsFiles()

$container = new ContainerBuilder();

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

$fileSystem = new Filesystem();
Expand Down

0 comments on commit 9cbab67

Please sign in to comment.