summaryrefslogtreecommitdiff
path: root/libs/picodb/tests/SqliteSchemaTest.php
diff options
context:
space:
mode:
authorFrédéric Guillot <fred@kanboard.net>2018-06-21 14:13:41 -0700
committerFrédéric Guillot <fred@kanboard.net>2018-06-21 14:13:41 -0700
commita491348d442ab8e6cd2fa403d4365cdad78e52ce (patch)
treea00f575d82afb2c9051bad95398b4250f4a3d44d /libs/picodb/tests/SqliteSchemaTest.php
parentc73ac5f1f818b6b21083f6785b4b2f6d778a6496 (diff)
Vendoring deprecated composer libs
Diffstat (limited to 'libs/picodb/tests/SqliteSchemaTest.php')
-rw-r--r--libs/picodb/tests/SqliteSchemaTest.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/libs/picodb/tests/SqliteSchemaTest.php b/libs/picodb/tests/SqliteSchemaTest.php
new file mode 100644
index 00000000..7522e10d
--- /dev/null
+++ b/libs/picodb/tests/SqliteSchemaTest.php
@@ -0,0 +1,36 @@
+<?php
+
+require_once __DIR__.'/../../../vendor/autoload.php';
+require_once __DIR__.'/SchemaFixture.php';
+
+class SqliteSchemaTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var PicoDb\Database
+ */
+ private $db;
+
+ public function setUp()
+ {
+ $this->db = new PicoDb\Database(array('driver' => 'sqlite', 'filename' => ':memory:'));
+ }
+
+ public function testMigrations()
+ {
+ $this->assertTrue($this->db->schema()->check(2));
+ $this->assertEquals(2, $this->db->getDriver()->getSchemaVersion());
+ }
+
+ public function testFailedMigrations()
+ {
+ $this->assertFalse($this->db->schema()->check(3));
+ $this->assertEquals(2, $this->db->getDriver()->getSchemaVersion());
+
+ $logs = $this->db->getLogMessages();
+ $this->assertNotEmpty($logs);
+ $this->assertEquals('Running migration \Schema\version_1', $logs[0]);
+ $this->assertEquals('Running migration \Schema\version_2', $logs[1]);
+ $this->assertEquals('Running migration \Schema\version_3', $logs[2]);
+ $this->assertEquals('SQLSTATE[HY000]: General error: 1 near "TABL": syntax error', $logs[3]);
+ }
+}