}); describe("->set()", function () { it("sets values", function () { $date = new DateTime('2014-10-26 00:25:15'); $document = new Document(); expect($document->set('title', 'Hello'))->toBe($document); expect($document->set('body', 'World'))->toBe($document); expect($document->set('created', $date))->toBe($document); expect($document->title)->toBe('Hello'); expect($document->body)->toBe('World'); expect($document->created)->toBe($date); expect($document)->toHaveLength(3); }); it("sets nested arbitraty value in cascade when locked is `false`", function () { $image = new Document(); $image->set('a.nested.value', 'hello'); expect($image->data())->toEqual(['a' => ['nested' => ['value' => 'hello']]]); }); it("returns `null` for undefined fields", function () { $document = new Document(); expect($document->foo)->toBe(null); }); it("sets an array of values", function () { $date = new DateTime('2014-10-26 00:25:15'); $document = new Document(); expect($document->set(['title' => 'Hello', 'body' => 'World', 'created' => $date]))->toBe($document); expect($document->title)->toBe('Hello'); expect($document->body)->toBe('World'); expect($document->created)->toBe($date); expect($document)->toHaveLength(3); });