DriverMock.php 1.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. namespace Doctrine\Tests\Mocks;
  3. class DriverMock implements \Doctrine\DBAL\Driver
  4. {
  5. private $_platformMock;
  6. private $_schemaManagerMock;
  7. public function connect(array $params, $username = null, $password = null, array $driverOptions = array())
  8. {
  9. return new DriverConnectionMock();
  10. }
  11. /**
  12. * Constructs the Sqlite PDO DSN.
  13. *
  14. * @return string The DSN.
  15. * @override
  16. */
  17. protected function _constructPdoDsn(array $params)
  18. {
  19. return "";
  20. }
  21. /**
  22. * @override
  23. */
  24. public function getDatabasePlatform()
  25. {
  26. if ( ! $this->_platformMock) {
  27. $this->_platformMock = new DatabasePlatformMock;
  28. }
  29. return $this->_platformMock;
  30. }
  31. /**
  32. * @override
  33. */
  34. public function getSchemaManager(\Doctrine\DBAL\Connection $conn)
  35. {
  36. if($this->_schemaManagerMock == null) {
  37. return new SchemaManagerMock($conn);
  38. } else {
  39. return $this->_schemaManagerMock;
  40. }
  41. }
  42. /* MOCK API */
  43. public function setDatabasePlatform(\Doctrine\DBAL\Platforms\AbstractPlatform $platform)
  44. {
  45. $this->_platformMock = $platform;
  46. }
  47. public function setSchemaManager(\Doctrine\DBAL\Schema\AbstractSchemaManager $sm)
  48. {
  49. $this->_schemaManagerMock = $sm;
  50. }
  51. public function getName()
  52. {
  53. return 'mock';
  54. }
  55. public function getDatabase(\Doctrine\DBAL\Connection $conn)
  56. {
  57. return;
  58. }
  59. }