$this->schema->drop(); }); it("creates a schema instance without introspection", function () { $gallery = $this->adapter->describe('gallery', $this->schema->columns()); expect($gallery->column('id'))->toEqual(['type' => 'serial', 'null' => false, 'array' => false]); expect($gallery->column('name'))->toEqual(['type' => 'string', 'length' => 128, 'null' => true, 'default' => 'Johnny Boy', 'array' => false]); expect($gallery->column('active'))->toEqual(['type' => 'boolean', 'null' => true, 'default' => true, 'array' => false]); expect($gallery->column('inactive'))->toEqual(['type' => 'boolean', 'null' => true, 'default' => false, 'array' => false]); expect($gallery->column('money'))->toEqual(['type' => 'decimal', 'length' => 10, 'precision' => 2, 'null' => true, 'array' => false]); expect($gallery->column('created'))->toEqual(['use' => 'timestamp', 'type' => 'datetime', 'null' => true, 'array' => false, 'default' => [':plain' => 'CURRENT_TIMESTAMP']]); }); }); describe("->save()", function () { it("casts data on insert using datasource handlers", function () { $schema = new Schema(['source' => 'test']); $schema->connection($this->adapter); $schema->column('id', ['type' => 'serial']); $schema->column('name', ['type' => 'string']); $schema->column('null', ['type' => 'string']); $schema->column('value', ['type' => 'integer']); $schema->column('double', ['type' => 'float']); $schema->column('revenue', ['type' => 'decimal', 'length' => 20, 'precision' => 2]); $schema->column('active', ['type' => 'boolean']); $schema->column('registered', ['type' => 'date']); $schema->column('created', ['type' => 'datetime']); $schema->create(); $schema->insert(['id' => 1, 'name' => 'test', 'null' => null, 'value' => 1234, 'double' => 1.5864, 'revenue' => '152000.8589', 'active' => true, 'registered' => DateTime::createFromFormat('Y-m-d H:i:s', '2016-07-30 00:00:00'), 'created' => DateTime::createFromFormat('Y-m-d H:i:s', '2016-07-30 04:38:55')]); $cursor = $schema->connection()->query('SELECT * FROM test WHERE id = 1'); $data = $cursor->next(); expect($data)->toBe(['id' => '1', 'name' => 'test', 'null' => null, 'value' => '1234', 'double' => '1.5864', 'revenue' => '152000.86', 'active' => '1', 'registered' => '2016-07-30', 'created' => '2016-07-30 04:38:55']); $cursor->close();