$schema->drop(); }); }); describe("->lastInsertId()", function () { it("gets the encoding last insert ID", function () { $schema = new Schema(['connection' => $this->adapter]); $schema->source('gallery'); $schema->column('id', ['type' => 'serial']); $schema->column('name', ['type' => 'string']); $schema->create(); $schema->insert(['name' => 'new gallery']); expect($schema->lastInsertId())->toBe("1"); $schema->drop(); }); it("gets the encoding last insert ID even with an empty record", function () { $schema = new Schema(['connection' => $this->adapter]); $schema->source('gallery'); $schema->column('id', ['type' => 'serial']); $schema->column('name', ['type' => 'string']); $schema->create(); $schema->insert([]); expect($schema->lastInsertId())->toBe("1"); $schema->drop(); }); }); describe("->query()", function () { it("throws an exception when an error occured", function () { $closure = function () { $this->adapter->query('SELECT'); }; expect($closure)->toThrow();
$schema->column('id', ['type' => 'serial']); $schema->create(); expect($this->connection->sources())->toBe(['test_table' => 'test_table']); $schema->drop(); expect($this->connection->sources())->toBe([]); }); it("throw an exception when source is not set", function () { $closure = function () { $schema = new Schema(['connection' => $this->connection]); $schema->create(); }; expect($closure)->toThrow(new DatabaseException("Missing table name for this schema.")); }); it("throw an exception when source is not set", function () { $closure = function () { $schema = new Schema(['connection' => $this->connection]); $schema->drop(); }; expect($closure)->toThrow(new DatabaseException("Missing table name for this schema.")); }); }); context("with all data populated", function () { beforeEach(function () { $this->fixtures->populate('gallery', ['records']); $this->fixtures->populate('gallery_detail', ['records']); $this->fixtures->populate('image', ['records']); $this->fixtures->populate('image_tag', ['records']); $this->fixtures->populate('tag', ['records']); }); describe("->embed()", function () { it("embeds a hasMany relationship", function () {