BaseDriverTrait.php 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. declare(strict_types=1);
  3. /**
  4. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  5. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  6. *
  7. * Licensed under The MIT License
  8. * For full copyright and license information, please see the LICENSE.txt
  9. * Redistributions of files must retain the above copyright notice.
  10. *
  11. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  12. * @link https://cakephp.org CakePHP(tm) Project
  13. * @since 5.1.0
  14. * @license https://opensource.org/licenses/mit-license.php MIT License
  15. */
  16. namespace Cake\Test\TestCase\Database\Driver;
  17. use Cake\Database\DriverFeatureEnum;
  18. use Cake\Database\Schema\SchemaDialect;
  19. use Cake\Database\Schema\SqliteSchemaDialect;
  20. use Mockery;
  21. trait BaseDriverTrait
  22. {
  23. public function connect(): void
  24. {
  25. $this->pdo = Mockery::mock('PDO')
  26. ->shouldReceive('inTransaction', 'beginTransaction')
  27. ->getMock();
  28. }
  29. public function enabled(): bool
  30. {
  31. return true;
  32. }
  33. public function disableForeignKeySQL(): string
  34. {
  35. return '';
  36. }
  37. public function enableForeignKeySQL(): string
  38. {
  39. return '';
  40. }
  41. public function schemaDialect(): SchemaDialect
  42. {
  43. return new SqliteSchemaDialect($this);
  44. }
  45. public function supports(DriverFeatureEnum $feature): bool
  46. {
  47. return true;
  48. }
  49. }