public function sqlite(UnitTester $I) { $I->wantToTest("Model validation by using SQLite as RDBMS"); /** @var \Phalcon\Di\FactoryDefault $di */ $di = Di::getDefault(); $connection = $di->getShared('db'); $di->remove('db'); $di->setShared('db', function () { $connection = new Sqlite(['dbname' => TEST_DB_SQLITE_NAME]); /** @var \PDO $pdo */ $pdo = $connection->getInternalHandler(); $pdo->sqliteCreateFunction('now', function () { return date('Y-m-d H:i:s'); }); return $connection; }); Di::setDefault($di); $this->success($I); $this->presenceOf($I); $this->email($I); $this->emailWithDot($I); $this->exclusionIn($I); $this->inclusionIn($I); $this->uniqueness1($I); $this->uniqueness2($I); $this->regex($I); $this->tooLong($I); $this->tooShort($I); $di->remove('db'); $di->setShared('db', $connection); }
protected function getBackend($prefix = '') { $frontend = new CacheFrontend(['lifetime' => 10]); $connection = new DbAdapter(['dbname' => ':memory:']); // Make table structure $connection->getInternalHandler()->exec('CREATE TABLE "cache_data" ("key_name" TEXT PRIMARY KEY, "data" TEXT, "lifetime" INTEGER)'); return new CacheBackend($frontend, ['db' => $connection, 'table' => 'cache_data', 'prefix' => $prefix]); }