public function testDescribeTable() { $this->loadFixtures(['Users', 'Stats']); $user = new User(); $this->assertEquals(['id' => ['field' => 'id', 'type' => 'int', 'length' => '11', 'null' => false, 'primary' => true, 'ai' => true], 'country_id' => ['field' => 'country_id', 'type' => 'int', 'length' => '11', 'null' => true, 'index' => true], 'username' => ['field' => 'username', 'type' => 'varchar', 'length' => '255', 'null' => false, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci', 'unique' => true], 'password' => ['field' => 'password', 'type' => 'varchar', 'length' => '255', 'null' => true, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci'], 'email' => ['field' => 'email', 'type' => 'varchar', 'length' => '255', 'null' => true, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci'], 'firstName' => ['field' => 'firstName', 'type' => 'varchar', 'length' => '255', 'null' => true, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci'], 'lastName' => ['field' => 'lastName', 'type' => 'varchar', 'length' => '255', 'null' => true, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci'], 'age' => ['field' => 'age', 'type' => 'smallint', 'length' => '6', 'null' => true], 'created' => ['field' => 'created', 'type' => 'datetime', 'length' => '', 'null' => true, 'default' => null], 'modified' => ['field' => 'modified', 'type' => 'datetime', 'length' => '', 'null' => true, 'default' => null]], $user->getDriver()->describeTable($user->getTable())); $stat = new Stat(); $this->assertEquals(['id' => ['field' => 'id', 'type' => 'int', 'length' => '11', 'null' => false, 'primary' => true, 'ai' => true], 'name' => ['field' => 'name', 'type' => 'varchar', 'length' => '255', 'null' => true, 'charset' => 'utf8', 'collate' => 'utf8_unicode_ci'], 'health' => ['field' => 'health', 'type' => 'int', 'length' => '11', 'null' => true], 'energy' => ['field' => 'energy', 'type' => 'smallint', 'length' => '6', 'null' => true], 'damage' => ['field' => 'damage', 'type' => 'float', 'length' => '', 'null' => true], 'defense' => ['field' => 'defense', 'type' => 'double', 'length' => '', 'null' => true], 'range' => ['field' => 'range', 'type' => 'decimal', 'length' => '8,2', 'null' => true], 'isMelee' => ['field' => 'isMelee', 'type' => 'tinyint', 'length' => '1', 'null' => true], 'data' => ['field' => 'data', 'type' => 'blob', 'length' => '', 'null' => true]], $user->getDriver()->describeTable($stat->getTable())); }
public function testUpdateTypeBlob() { $this->loadFixtures('Stats'); $handle = fopen(TEMP_DIR . '/blob.txt', 'rb'); $stat = new Stat(); $this->assertEquals(1, $stat->update(1, ['data' => $handle])); // Match row $expected = $stat->select()->where('id', 1)->first()->toArray(); $handle = $expected['data']; $expected['data'] = stream_get_contents($handle, -1, 0); fclose($handle); $this->assertEquals(['id' => 1, 'name' => 'Warrior', 'health' => 1500, 'energy' => 150, 'damage' => 125.25, 'defense' => 55.75, 'range' => 1.0, 'isMelee' => true, 'data' => 'This is loading from a file handle'], $expected); }