|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Bridge\Doctrine\Tests\SchemaListener; |
| 13 | + |
| 14 | +use Doctrine\DBAL\Connection; |
| 15 | +use Doctrine\DBAL\Schema\Schema; |
| 16 | +use Doctrine\ORM\EntityManagerInterface; |
| 17 | +use Doctrine\ORM\Tools\Event\GenerateSchemaEventArgs; |
| 18 | +use PHPUnit\Framework\TestCase; |
| 19 | +use Symfony\Bridge\Doctrine\SchemaListener\DoctrineDbalCacheAdapterSchemaSubscriber; |
| 20 | +use Symfony\Component\Cache\Adapter\DoctrineSchemaConfiguratorInterface; |
| 21 | + |
| 22 | +class DoctrineDbalCacheAdapterSchemaSubscriberTest extends TestCase |
| 23 | +{ |
| 24 | + public function testPostGenerateSchema() |
| 25 | + { |
| 26 | + $schema = new Schema(); |
| 27 | + $dbalConnection = $this->createMock(Connection::class); |
| 28 | + $entityManager = $this->createMock(EntityManagerInterface::class); |
| 29 | + $entityManager->expects($this->once()) |
| 30 | + ->method('getConnection') |
| 31 | + ->willReturn($dbalConnection); |
| 32 | + $event = new GenerateSchemaEventArgs($entityManager, $schema); |
| 33 | + |
| 34 | + $pdoAdapter = $this->createMock(DoctrineSchemaConfiguratorInterface::class); |
| 35 | + $pdoAdapter->expects($this->once()) |
| 36 | + ->method('configureSchema') |
| 37 | + ->with($schema, $dbalConnection); |
| 38 | + |
| 39 | + $subscriber = new DoctrineDbalCacheAdapterSchemaSubscriber([$pdoAdapter]); |
| 40 | + $subscriber->postGenerateSchema($event); |
| 41 | + } |
| 42 | +} |
0 commit comments