Ejemplo n.º 1
0
 /**
  * Tests to make sure we can serialize and unserialize a model
  *
  * @return  void
  **/
 public function testCanDoSimpleSerialization()
 {
     $user = User::oneOrFail(1);
     $serialized = serialize($user);
     $unserialized = unserialize($serialized);
     $this->assertEquals($user, $unserialized, 'Unserialize did not result in the original model');
 }
Ejemplo n.º 2
0
 /**
  * Tests to make sure we can get relationships defined on a model, including runtime relationships
  *
  * @return  void
  **/
 public function testCanIntrospectRelationshipsIncludingRuntimeRelationships()
 {
     // Note that we're expecting the relationship registered in the previous test
     $this->assertEquals(['posts', 'bio'], User::introspectRelationships(), 'User should have had two relationships of "posts" and "bio"');
 }
Ejemplo n.º 3
0
 /**
  * Tests to make sure saving a one to many relationship properly sets the associated field on the related side
  *
  * @return  void
  **/
 public function testSaveOneToManyAssociatesRelated()
 {
     User::oneOrFail(1)->posts()->save(['content' => 'This is a test post']);
     $this->assertArrayHasKey('user_id', User::oneOrFail(1)->posts->last(), 'Saved item should have automatically included a user_id');
 }