public function setUp()
 {
     $this->pdo = new PDO("sqlite::memory:");
     $this->pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     $this->pdo->exec('create table `stuff` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` varchar(100), `box_id` INTEGER NULL DEFAULT NULL);');
     $this->pdo->exec('create table `box` ( `id` INTEGER PRIMARY KEY AUTOINCREMENT, `name` varchar(100) );');
     $this->pdo->exec('CREATE TABLE `some_stuff` (
       `some_id` int(10)  NOT NULL,
       `stuff_id` int(10)  NOT NULL,
       `name` VARCHAR(100),
       PRIMARY KEY (`some_id`,`stuff_id`));');
     \DerpTest\Machinist\Machinist::store(SqlStore::fromPdo($this->pdo));
 }
Example #2
0
 public function testSqlStoreGetsInstance()
 {
     $this->assertInstanceOf('\\DerpTest\\Machinist\\Store\\Sqlite', SqlStore::fromPdo($this->pdo));
 }
Example #3
0
 /**
  * Wipe all data in the data store for the provided table
  * @param string $table Name of table to delete all rows
  * @param bool $truncate SQLite does not support truncate
  */
 public function wipe($table, $truncate)
 {
     return parent::wipe($table, false);
 }
Example #4
0
 public function wipe($table, $truncate)
 {
     $should_toggle_foreign_key = $this->isForeignKeyChecksEnabled();
     if ($should_toggle_foreign_key) {
         $this->disableForeignKeyCheck();
     }
     parent::wipe($table, $truncate);
     if ($should_toggle_foreign_key) {
         //re-enable
         $this->enableForeignKeyCheck();
     }
 }
Example #5
0
 public function testFromPdoSetsErrorMode()
 {
     \DerpTest\Machinist\Store\SqlStore::fromPdo($this->pdo, \PDO::ERRMODE_WARNING);
     \Phake::verify($this->pdo)->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_WARNING);
 }