コード例 #1
0
 public function setUp()
 {
     $manager = new AccountManager();
     $manager->username = '******';
     $manager->password = '******';
     $manager->email = '*****@*****.**';
     $manager->created_at = '2016-01-13 00:06:16';
     $manager->updated_at = '2016-01-13 00:06:16';
     $manager->timestamps = false;
     $manager->save();
     $user = new User();
     $user->account_manager_id = $manager->id;
     $user->username = '******';
     $user->password = '******';
     $user->email = '*****@*****.**';
     $user->created_at = '2016-01-13 00:06:16';
     $user->updated_at = '2016-01-13 00:06:16';
     $user->timestamps = false;
     $user->save();
 }
コード例 #2
0
 public function testSerializeCollectionWithHasManyThroughAndMorp()
 {
     /* get a serialized collection by using a "HasManyThrough" relation */
     $user_orders = AccountManager::with('orders')->find(1);
     $driver = new EloquentDriver();
     $output = $driver->serialize($user_orders);
     $expected = array('@type' => 'NilPortugues\\Tests\\Serializer\\Drivers\\Eloquent\\Models\\AccountManager', 'id' => array('@scalar' => 'integer', '@value' => '1'), 'username' => array('@scalar' => 'string', '@value' => 'Joe'), 'password' => array('@scalar' => 'string', '@value' => 'password'), 'email' => array('@scalar' => 'string', '@value' => '*****@*****.**'), 'created_at' => array('@scalar' => 'string', '@value' => '2016-01-13 00:06:16'), 'updated_at' => array('@scalar' => 'string', '@value' => '2016-01-13 00:06:16'), 'deleted_at' => array('@scalar' => 'NULL', '@value' => null), 'orders' => array('@map' => 'array', '@value' => array(0 => array('@type' => 'NilPortugues\\Tests\\Serializer\\Drivers\\Eloquent\\Models\\Orders', 'user_id' => array('@scalar' => 'string', '@value' => '1'), 'id' => array('@scalar' => 'integer', '@value' => '1'), 'name' => array('@scalar' => 'string', '@value' => 'Some item'), 'ordered_at' => array('@scalar' => 'string', '@value' => '2016-01-14 09:15:20'), 'account_manager_id' => array('@scalar' => 'string', '@value' => '1')))), 'likes' => array('@map' => 'array', '@value' => array(0 => array('@type' => 'NilPortugues\\Tests\\Serializer\\Drivers\\Eloquent\\Models\\Like', 'id' => array('@scalar' => 'integer', '@value' => 2), 'user_id' => array('@scalar' => 'string', '@value' => '1'), 'likeable_id' => array('@scalar' => 'string', '@value' => '1'), 'likeable_type' => array('@scalar' => 'string', '@value' => 'NilPortugues\\Tests\\Serializer\\Drivers\\Eloquent\\Models\\AccountManager'), 'created_at' => array('@scalar' => 'string', '@value' => '2016-01-22 11:33:41'), 'updated_at' => array('@scalar' => 'string', '@value' => '2016-01-22 11:33:41')))));
     $this->assertEquals($expected, $output);
 }