summaryrefslogtreecommitdiff
path: root/libs/picodb/tests/SqliteDriverTest.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/SqliteDriverTest.php
parentc73ac5f1f818b6b21083f6785b4b2f6d778a6496 (diff)
Vendoring deprecated composer libs
Diffstat (limited to 'libs/picodb/tests/SqliteDriverTest.php')
-rw-r--r--libs/picodb/tests/SqliteDriverTest.php70
1 files changed, 70 insertions, 0 deletions
diff --git a/libs/picodb/tests/SqliteDriverTest.php b/libs/picodb/tests/SqliteDriverTest.php
new file mode 100644
index 00000000..9965a39c
--- /dev/null
+++ b/libs/picodb/tests/SqliteDriverTest.php
@@ -0,0 +1,70 @@
+<?php
+
+require_once __DIR__.'/../../../vendor/autoload.php';
+
+use PicoDb\Driver\Sqlite;
+
+class SqliteDriverTest extends PHPUnit_Framework_TestCase
+{
+ /**
+ * @var PicoDb\Driver\Sqlite
+ */
+ private $driver;
+
+ public function setUp()
+ {
+ $this->driver = new Sqlite(array('filename' => ':memory:'));
+ }
+
+ /**
+ * @expectedException LogicException
+ */
+ public function testMissingRequiredParameter()
+ {
+ new Sqlite(array());
+ }
+
+ public function testDuplicateKeyError()
+ {
+ $this->assertFalse($this->driver->isDuplicateKeyError(1234));
+ $this->assertTrue($this->driver->isDuplicateKeyError(23000));
+ }
+
+ public function testOperator()
+ {
+ $this->assertEquals('LIKE', $this->driver->getOperator('LIKE'));
+ $this->assertEquals('LIKE', $this->driver->getOperator('ILIKE'));
+ $this->assertEquals('', $this->driver->getOperator('FOO'));
+ }
+
+ public function testSchemaVersion()
+ {
+ $this->assertEquals(0, $this->driver->getSchemaVersion());
+
+ $this->driver->setSchemaVersion(1);
+ $this->assertEquals(1, $this->driver->getSchemaVersion());
+
+ $this->driver->setSchemaVersion(42);
+ $this->assertEquals(42, $this->driver->getSchemaVersion());
+ }
+
+ public function testLastInsertId()
+ {
+ $this->assertEquals(0, $this->driver->getLastId());
+
+ $this->driver->getConnection()->exec('CREATE TABLE foobar (id INTEGER PRIMARY KEY, something TEXT)');
+ $this->driver->getConnection()->exec('INSERT INTO foobar (something) VALUES (1)');
+
+ $this->assertEquals(1, $this->driver->getLastId());
+ }
+
+ public function testEscape()
+ {
+ $this->assertEquals('"foobar"', $this->driver->escape('foobar'));
+ }
+
+ public function testDatabaseVersion()
+ {
+ $this->assertStringStartsWith('3.', $this->driver->getDatabaseVersion());
+ }
+}