FakeConnection.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. declare(strict_types=1);
  3. namespace TestApp\Datasource;
  4. use Cake\Datasource\ConnectionInterface;
  5. use Psr\Log\LoggerInterface;
  6. use Psr\SimpleCache\CacheInterface;
  7. use RuntimeException;
  8. class FakeConnection implements ConnectionInterface
  9. {
  10. protected $_config = [];
  11. /**
  12. * Constructor.
  13. *
  14. * @param array $config configuration for connecting to database
  15. */
  16. public function __construct($config = [])
  17. {
  18. $this->_config = $config;
  19. }
  20. /**
  21. * Returns the set config
  22. *
  23. * @return array
  24. */
  25. public function config(): array
  26. {
  27. return $this->_config;
  28. }
  29. /**
  30. * Returns the set name
  31. */
  32. public function configName(): string
  33. {
  34. if (empty($this->_config['name'])) {
  35. return '';
  36. }
  37. return $this->_config['name'];
  38. }
  39. public function getDriver(string $role = self::ROLE_WRITE): object
  40. {
  41. throw new RuntimeException('Not implemented');
  42. }
  43. public function getLogger(): LoggerInterface
  44. {
  45. throw new RuntimeException('Not implemented');
  46. }
  47. public function setLogger(LoggerInterface $logger): void
  48. {
  49. }
  50. public function setCacher(CacheInterface $cacher): never
  51. {
  52. throw new RuntimeException('Not implemented');
  53. }
  54. public function getCacher(): CacheInterface
  55. {
  56. throw new RuntimeException('Not implemented');
  57. }
  58. public function enableQueryLogging(bool $enable = true)
  59. {
  60. return $this;
  61. }
  62. public function disableQueryLogging()
  63. {
  64. return $this;
  65. }
  66. public function isQueryLoggingEnabled(): bool
  67. {
  68. return false;
  69. }
  70. }