Esempio n. 1
0
 });
 describe("->lastInsertId()", function () {
     it("gets the encoding last insert ID", function () {
         $schema = new Schema(['connection' => $this->adapter]);
         $schema->source('gallery');
         $schema->set('id', ['type' => 'serial']);
         $schema->set('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->set('id', ['type' => 'serial']);
         $schema->set('name', ['type' => 'string']);
         $schema->create();
         $schema->insert([]);
         expect($schema->lastInsertId())->toBe("1");
         $schema->drop();
     });
 });
 describe("->query", function () {
     it("returns an invalid cursor when an error occurs in silent mode", function () {
         $cursor = $this->adapter->query('SELECT', [], ['exception' => false]);
         expect($cursor->error())->toBe(true);
     });
 });
 describe("->encoding()", function () {
     it("gets/sets the encoding", function () {
Esempio n. 2
0
     $this->fixtures->reset();
 });
 describe("->query()", function () {
     it("throw an exception when no model is set", function () {
         $closure = function () {
             $schema = new Schema(['connection' => $this->connection]);
             $schema->query();
         };
         expect($closure)->toThrow(new DatabaseException("Missing model for this schema, can't create a query."));
     });
 });
 describe("->create()/->drop()", function () {
     it("creates/drop a table", function () {
         $this->fixtures->drop();
         $schema = new Schema(['connection' => $this->connection, 'source' => 'test_table']);
         $schema->set('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]);