From e03565fd6ed6d4604868bfe0abec2fb3f565d0b5 Mon Sep 17 00:00:00 2001 From: Nikolaos Dimopoulos Date: Sat, 25 Jan 2020 19:30:50 -0500 Subject: [PATCH] [#14733] - Fixtures for DM --- .../fixtures/DM/Pdo/ConnectionFixture.php | 29 +++++++ tests/_data/fixtures/DM/Pdo/PdoFixture.php | 20 +++++ tests/_data/fixtures/Migrations/Invoices.php | 79 +++++++++++++++++++ tests/_data/fixtures/Resultset.php | 22 ++++++ 4 files changed, 150 insertions(+) create mode 100644 tests/_data/fixtures/DM/Pdo/ConnectionFixture.php create mode 100644 tests/_data/fixtures/DM/Pdo/PdoFixture.php create mode 100644 tests/_data/fixtures/Migrations/Invoices.php create mode 100644 tests/_data/fixtures/Resultset.php diff --git a/tests/_data/fixtures/DM/Pdo/ConnectionFixture.php b/tests/_data/fixtures/DM/Pdo/ConnectionFixture.php new file mode 100644 index 00000000000..1bced8991d0 --- /dev/null +++ b/tests/_data/fixtures/DM/Pdo/ConnectionFixture.php @@ -0,0 +1,29 @@ +pdo = new PdoFixture(); + } +} diff --git a/tests/_data/fixtures/DM/Pdo/PdoFixture.php b/tests/_data/fixtures/DM/Pdo/PdoFixture.php new file mode 100644 index 00000000000..824a041fbd7 --- /dev/null +++ b/tests/_data/fixtures/DM/Pdo/PdoFixture.php @@ -0,0 +1,20 @@ + + * + * For the full copyright and license information, please view the LICENSE.txt + * file that was distributed with this source code. + */ + +declare(strict_types=1); + +namespace Phalcon\Test\Fixtures\Migrations; + +use Phalcon\DM\Pdo\Connection; + +use function date; +use function uniqid; + +class Invoices +{ + /** + * Invoices constructor. + * + * @param Connection $connection + */ + public function __construct(Connection $connection) + { + $this->truncate($connection); + } + + /** + * @param Connection $connection + * @param int $id + * @param string|null $title + * + * @return int + */ + public function insert( + Connection $connection, + int $id, + string $title = null + ): int { + $title = $title ?: uniqid(); + $now = date('Y-m-d H:i:s'); + $total = 100 + $id; + $flag = (int) ($id % 2); + $sql = <<exec($sql); + } + + /** + * @param Connection $connection + */ + public function truncate(Connection $connection): void + { + $sql = "delete from co_invoices"; + + $connection->exec($sql); + } +} diff --git a/tests/_data/fixtures/Resultset.php b/tests/_data/fixtures/Resultset.php new file mode 100644 index 00000000000..85b95005834 --- /dev/null +++ b/tests/_data/fixtures/Resultset.php @@ -0,0 +1,22 @@ +calculated = $calculated; + } +} \ No newline at end of file