Ejemplo n.º 1
0
 public function createUsersWithAsocs($count)
 {
     for ($i = 1; $i <= $count; $i++) {
         $user = User::create(['login' => 'login_' . $i, 'password' => 'password_' . $i, 'email' => 'email_' . $i . '@example.com']);
         $profile = Profile::create(['userId' => $user->id, 'sign' => 'signature of user ' . $user->id]);
         for ($j = 1; $j <= $count; $j++) {
             $relation = UserAndGroupRelation::create(['userId' => $user->id, 'groupId' => $j]);
             $post = BlogPost::create(['userId' => $user->id, 'title' => "Post {$i}", 'message' => "This is a message {$i}!", 'createdAt' => time() + $i]);
             for ($k = 1; $k <= $count; $k++) {
                 $comment = BlogComment::create(['userId' => $user->id, 'blogPostId' => $post->id, 'title' => "Comment {$j} to post {$i}", 'message' => "This is a comment message {$i}:{$j}!", 'createdAt' => time() + $j]);
             }
         }
     }
 }
Ejemplo n.º 2
0
 public function createUsersWithGroups($usersCount, $groupsCount)
 {
     // user login_1 is a member of all the groups
     // group name_1 contains all users
     for ($i = 1; $i <= $groupsCount; $i++) {
         $group = Group::create(['name' => 'name_' . $i]);
     }
     $group1 = Group::findFirst(['conditions' => "name = 'name_1'"]);
     for ($i = 1; $i <= $usersCount; $i++) {
         $user = User::create(['login' => 'login_' . $i, 'password' => 'password_' . $i, 'email' => 'email_' . $i . '@example.com']);
         if ($i == 1) {
             for ($j = 1; $j <= $groupsCount; $j++) {
                 $group = Group::findFirst(['conditions' => "name = 'name_" . $j . "'"]);
                 $relation = UserAndGroupRelation::create(['userId' => $user->id, 'groupId' => $group->id]);
             }
         } else {
             $relation = UserAndGroupRelation::create(['userId' => $user->id, 'groupId' => $group1->id]);
         }
     }
 }