Skip to content

Commit

Permalink
Merge pull request #838 from doctrine/5.0.x-merge-up-into-5.1.x_oewv85CN
Browse files Browse the repository at this point in the history
Merge release 5.0.1 into 5.1.x
  • Loading branch information
GromNaN authored Jan 16, 2024
2 parents 2467b09 + 4d8d32b commit 9ceabb9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Command/DoctrineODMCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public function __construct(private ManagerRegistry $registry)
parent::__construct();
}

public static function setApplicationDocumentManager(Application $application, string $dmName): void
public static function setApplicationDocumentManager(Application $application, ?string $dmName): void
{
$dm = $application->getKernel()->getContainer()->get('doctrine_mongodb')->getManager($dmName);
$helperSet = $application->getHelperSet();
Expand Down
31 changes: 31 additions & 0 deletions tests/Command/DoctrineODMCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Doctrine\Bundle\MongoDBBundle\Tests\Command;

use Doctrine\Bundle\MongoDBBundle\Command\DoctrineODMCommand;
use Doctrine\ODM\MongoDB\Tools\Console\Helper\DocumentManagerHelper;
use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase;

class DoctrineODMCommandTest extends KernelTestCase
{
/** @dataProvider provideDmName */
public function testSetApplicationManager(?string $dmName): void
{
$kernel = new CommandTestKernel('test', false);
$kernel->boot();
$application = new Application($kernel);

DoctrineODMCommand::setApplicationDocumentManager($application, $dmName);

$this->assertInstanceOf(DocumentManagerHelper::class, $application->getHelperSet()->get('dm'));
}

public static function provideDmName(): iterable
{
yield ['command_test'];
yield [null];
}
}

0 comments on commit 9ceabb9

Please sign in to comment.