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