예제 #1
0
     $this->schema->bind('tags', ['relation' => 'hasManyThrough', 'to' => Tag::class, 'through' => 'images_tags', 'using' => 'tag']);
 });
 describe("->__construct()", function () {
     it("correctly sets config options", function () {
         $connection = Stub::create();
         $conventions = Stub::create();
         Stub::on($connection)->method('formatters')->andReturn([]);
         $schema = new Schema(['connection' => $connection, 'source' => 'image', 'model' => Image::class, 'primaryKey' => 'key', 'locked' => false, 'fields' => ['id' => 'serial', 'age' => 'integer'], 'meta' => ['some' => ['meta']], 'conventions' => $conventions]);
         expect($schema->connection())->toBe($connection);
         expect($schema->source())->toBe('image');
         expect($schema->model())->toBe(Image::class);
         expect($schema->primaryKey())->toBe('key');
         expect($schema->locked())->toBe(false);
         expect($schema->fields())->toBe(['id' => ['type' => 'serial', 'array' => false, 'null' => false], 'age' => ['type' => 'integer', 'array' => false, 'null' => true]]);
         expect($schema->meta())->toBe(['some' => ['meta']]);
         expect($schema->conventions())->toBe($conventions);
     });
 });
 describe("->connection()", function () {
     it("gets/sets the connection", function () {
         $connection = Stub::create();
         $schema = new Schema();
         expect($schema->connection($connection))->toBe($schema);
         expect($schema->connection())->toBe($connection);
     });
 });
 describe("->source()", function () {
     it("gets/sets the source", function () {
         $schema = new Schema();
         expect($schema->source('source_name'))->toBe($schema);
         expect($schema->source())->toBe('source_name');