summaryrefslogtreecommitdiff
path: root/scripts/create-random-tasks.php
blob: 203c414dba57fb7df439fdf4d3c8f365d21e1e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env php
<?php

require __DIR__.'/../app/common.php';

use Model\TaskCreation;
use Model\Subtask;
use Model\Project;
use Model\ProjectPermission;
use Model\User;

$task_per_column = 200;

$userModel = new User($container);
$projectModel = new Project($container);
$permissionModel = new ProjectPermission($container);
$taskModel = new TaskCreation($container);
$subtaskModel = new Subtask($container);

$project_id = $projectModel->create(array(
    'name' => 'Project #1'
));

$permissionModel->addMember($project_id, 1);

for ($i = 0; $i <= 5; $i++) {
    $userModel->create(array(
        'username' => 'user'.$i,
        'password' => 'password'.$i,
        'name' => 'User #'.$i,
        'email' => 'user'.$i.'@localhost',
    ));
}

foreach (array(1, 2, 3, 4) as $column_id) {

    for ($i = 1; $i <= $task_per_column; $i++) {

        $task = array(
            'title' => 'Task #'.$i.'-'.$column_id,
            'project_id' => 1,
            'column_id' => $column_id,
            'owner_id' => 1,
            'color_id' => mt_rand(0, 1) === 0 ? 'green' : 'purple',
            'score' => mt_rand(0, 21),
            'is_active' => mt_rand(0, 1),
        );

        $id = $taskModel->create($task);

        $subtaskModel->create(array(
            'title' => 'Subtask of task #'.$id,
            'user_id' => 1,
            'status' => mt_rand(0, 2),
            'task_id' => $id,
        ));
    }
}