1
0
mirror of synced 2024-12-14 07:06:04 +03:00
doctrine2/tests/Doctrine/Tests/Mocks/DriverMock.php

89 lines
1.8 KiB
PHP
Raw Normal View History

2008-09-12 21:25:38 +04:00
<?php
namespace Doctrine\Tests\Mocks;
2009-01-04 19:15:32 +03:00
/**
* Mock class for Driver.
*/
class DriverMock implements \Doctrine\DBAL\Driver
2008-09-12 21:25:38 +04:00
{
/**
* @var \Doctrine\DBAL\Platforms\AbstractPlatform|null
*/
private $_platformMock;
/**
* @var \Doctrine\DBAL\Schema\AbstractSchemaManager|null
*/
private $_schemaManagerMock;
/**
* {@inheritdoc}
*/
2008-09-12 21:25:38 +04:00
public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
{
return new DriverConnectionMock();
2008-09-12 21:25:38 +04:00
}
2011-12-20 01:56:19 +04:00
/**
* {@inheritdoc}
*/
2008-09-12 21:25:38 +04:00
public function getDatabasePlatform()
{
if ( ! $this->_platformMock) {
$this->_platformMock = new DatabasePlatformMock;
}
return $this->_platformMock;
2008-09-12 21:25:38 +04:00
}
/**
* {@inheritdoc}
*/
public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
2008-09-12 21:25:38 +04:00
{
if ($this->_schemaManagerMock == null) {
return new SchemaManagerMock($conn);
} else {
return $this->_schemaManagerMock;
}
2008-09-12 21:25:38 +04:00
}
/* MOCK API */
/**
* @param \Doctrine\DBAL\Platforms\AbstractPlatform $platform
*
* @return void
*/
public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
{
$this->_platformMock = $platform;
}
/**
* @param \Doctrine\DBAL\Schema\AbstractSchemaManager $sm
*
* @return void
*/
public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm)
{
$this->_schemaManagerMock = $sm;
}
/**
* {@inheritdoc}
*/
public function getName()
{
return 'mock';
}
/**
* {@inheritdoc}
*/
public function getDatabase(\Doctrine\DBAL\Connection $conn)
{
return;
}
}