/** * Regression test for creating recursively connected models. * * @see https://github.com/Vinelab/NeoEloquent/issues/7 */ public function testCreatingModelWithExistingRecursivelyRelatedModel() { $jon = User::create(['name' => 'Jon Ronson']); $morgan = User::create(['name' => 'Morgan Spurlock']); $user = User::createWith(['name' => 'Ken Robinson'], ['colleagues' => [$morgan, $jon]]); $this->assertInstanceOf('Vinelab\\NeoEloquent\\Tests\\Functional\\QueryingRelations\\User', $user); }
public function testSavingCreateWithRelationWithDateTimeAndCarbonInstances() { $yesterday = Carbon::now()->subDay(); $dt = new DateTime(); $user = User::createWith(['name' => 'Some Name', 'dob' => $yesterday], ['colleagues' => ['name' => 'Protectron', 'dob' => $dt]]); $houwe = User::first(); $colleague = $houwe->colleagues()->first(); $this->assertEquals($yesterday->format(User::getDateFormat()), $houwe->dob); $this->assertEquals($dt->format(User::getDateFormat()), $colleague->dob); }