/**
  * 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);
 }
Ejemplo n.º 2
0
 public function testSavingRelationWithDateTimeAndCarbonInstances()
 {
     $user = User::create(['name' => 'Andrew Hale']);
     $yesterday = Carbon::now()->subDay();
     $brother = new User(['name' => 'Simon Hale', 'dob' => $yesterday]);
     $dt = new DateTime();
     $someone = User::create(['name' => 'Producer', 'dob' => $dt]);
     $user->colleagues()->save($someone);
     $user->colleagues()->save($brother);
     $andrew = User::first();
     $colleagues = $andrew->colleagues()->get();
     $this->assertEquals($dt->format(User::getDateFormat()), $colleagues[0]->dob);
     $this->assertEquals($yesterday->format(User::getDateFormat()), $colleagues[1]->dob);
 }