-
-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make DoctrineBundle compatible with ORM 2.9 (#1327)
Co-authored-by: Gabriel Ostrolucký <gabriel.ostrolucky@gmail.com>
- Loading branch information
1 parent
09339f7
commit d6b3c37
Showing
16 changed files
with
171 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<?php | ||
|
||
namespace Command\Proxy; | ||
|
||
use Doctrine\Bundle\DoctrineBundle\Command\Proxy\InfoDoctrineCommand; | ||
use Doctrine\DBAL\Connection; | ||
use Doctrine\ORM\Configuration; | ||
use Doctrine\ORM\EntityManagerInterface; | ||
use Doctrine\Persistence\Mapping\Driver\MappingDriverChain; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Bridge\Doctrine\ManagerRegistry; | ||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
use Symfony\Component\Console\Tester\CommandTester; | ||
use Symfony\Component\DependencyInjection\ContainerInterface; | ||
use Symfony\Component\HttpKernel\Kernel; | ||
|
||
use function array_merge; | ||
|
||
class InfoDoctrineCommandTest extends TestCase | ||
{ | ||
public function testExecute(): void | ||
{ | ||
$kernel = $this->setupKernelMocks(); | ||
|
||
$application = new Application($kernel); | ||
$application->add(new InfoDoctrineCommand()); | ||
|
||
$command = $application->find('doctrine:mapping:info'); | ||
|
||
$commandTester = new CommandTester($command); | ||
$commandTester->execute( | ||
array_merge(['command' => $command->getName()]) | ||
); | ||
|
||
$this->assertStringContainsString( | ||
'You do not have any mapped Doctrine ORM entities', | ||
$commandTester->getDisplay() | ||
); | ||
} | ||
|
||
/** | ||
* @return MockObject&Kernel | ||
*/ | ||
private function setupKernelMocks(): MockObject | ||
{ | ||
$configuration = new Configuration(); | ||
$configuration->setMetadataDriverImpl(new MappingDriverChain()); | ||
|
||
$connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); | ||
|
||
$manager = $this->getMockBuilder(EntityManagerInterface::class)->getMock(); | ||
$manager->method('getConnection')->willReturn($connection); | ||
$manager->method('getConfiguration')->willReturn($configuration); | ||
|
||
$registry = $this->getMockBuilder(ManagerRegistry::class)->disableOriginalConstructor()->getMock(); | ||
$registry->method('getManager')->willReturn($manager); | ||
|
||
$container = $this->getMockBuilder(ContainerInterface::class)->getMock(); | ||
$container->method('get')->willReturn($registry); | ||
|
||
$kernel = $this->getMockBuilder(Kernel::class); | ||
$kernel->disableOriginalConstructor(); | ||
$kernel = $kernel->getMock(); | ||
$kernel->method('getBundles')->willReturn([]); | ||
$kernel->method('getContainer')->willReturn($container); | ||
|
||
return $kernel; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters