DoctrineOpenTransactionLoggerMiddleware example


        };

        $this->connection = $this->createMock(Connection::class);

        $this->entityManager = $this->createMock(EntityManagerInterface::class);
        $this->entityManager->method('getConnection')->willReturn($this->connection);

        $managerRegistry = $this->createMock(ManagerRegistry::class);
        $managerRegistry->method('getManager')->willReturn($this->entityManager);

        $this->middleware = new DoctrineOpenTransactionLoggerMiddleware($managerRegistry, null, $this->logger);
    }

    public function testMiddlewareWrapsInTransactionAndFlushes()
    {
        $this->connection->expects($this->exactly(1))
            ->method('isTransactionActive')
            ->will($this->onConsecutiveCalls(true, true, false))
        ;

        $this->middleware->handle(new Envelope(new \stdClass())$this->getStackMock());

        
Home | Imprint | This part of the site doesn't use cookies.