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