/** * Create a new database connection mock object for every test. * * @return void */ protected function setUp() { parent::setUp(); $this->connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->getMock(); $this->connection->expects($this->any())->method('quoteIdentifier')->will($this->returnArgument(0)); $this->connection->expects($this->any())->method('getDatabasePlatform')->will($this->returnValue(new MockPlatform())); }
/** * @test */ public function getServerVersionReportsPlatformVersion() { /** @var MysqliConnection|ObjectProphecy $driverProphet */ $driverProphet = $this->prophesize(\Doctrine\DBAL\Driver\Mysqli\Driver::class); $driverProphet->willImplement(\Doctrine\DBAL\VersionAwarePlatformDriver::class); /** @var MysqliConnection|ObjectProphecy $wrappedConnectionProphet */ $wrappedConnectionProphet = $this->prophesize(\Doctrine\DBAL\Driver\Mysqli\MysqliConnection::class); $wrappedConnectionProphet->willImplement(\Doctrine\DBAL\Driver\ServerInfoAwareConnection::class); $wrappedConnectionProphet->requiresQueryForServerVersion()->willReturn(false); $wrappedConnectionProphet->getServerVersion()->willReturn('5.7.11'); $this->connection->expects($this->any())->method('getDriver')->willReturn($driverProphet->reveal()); $this->connection->expects($this->any())->method('getWrappedConnection')->willReturn($wrappedConnectionProphet->reveal()); $this->assertSame('mock 5.7.11', $this->connection->getServerVersion()); }