Ejemplo n.º 1
0
 function test_deleteAll()
 {
     $description = "Wash the dog";
     $description2 = "Water the lawn";
     $test_Task = new Task($description);
     $test_Task->save();
     $test_Task2 = new Task($description2);
     $test_Task2->save();
     Task::deleteAll();
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 2
0
 function test_deleteAll()
 {
     //Arrange
     $description = "Wash the dog";
     $due_date = '2015-01-01';
     $id = 1;
     $test_task = new Task($description, $id, $due_date);
     $test_task->save();
     $description2 = "Water the lawn";
     $id2 = 2;
     $due_date = '2015-01-02';
     $test_task2 = new Task($description2, $id, $due_date);
     $test_task2->save();
     //Act
     Task::deleteAll();
     //Asser
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 3
0
 function test_deleteAll()
 {
     // Arrange
     $name = "Home stuff";
     $id = null;
     $test_category = new Category($name, $id);
     $description = "Wash the dog";
     $category_id = $test_category->getId();
     $test_task = new Task($description, $id, $category_id);
     $test_task->save();
     $description2 = "Water the lawn";
     $test_task2 = new Task($description2, $id, $category_id);
     $test_task2->save();
     // Act
     Task::deleteAll();
     // Assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 4
0
 function test_deleteAll()
 {
     //Arrange
     $id = 1;
     $description = "Wash the dog";
     $date_due = "1990-12-11";
     $time_due = "09:00:00";
     $test_task = new Task($id, $description, $date_due, $time_due);
     $test_task->save();
     $id2 = 2;
     $description2 = "Water the lawn";
     $date_due2 = "1990-11-11";
     $time_due2 = "09:01:00";
     $test_task2 = new Task($id2, $description2, $date_due2, $time_due2);
     $test_task2->save();
     //act
     Task::deleteAll();
     //assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 5
0
 function test_deleteAll()
 {
     $name = "Home stuff";
     $id = null;
     $test_category = new Category($name, $id);
     $test_category->save();
     $description = "Wash the dog";
     $date_due = "9/25/1990";
     $time_due = "9:00am";
     $category_id = $test_category->getId();
     $test_task = new Task($id, $description, $date_due, $time_due, $category_id);
     $test_task->save();
     $description2 = "Water the Lawn";
     $date_due2 = "3/28/2000";
     $time_due2 = "10:00am";
     $test_task2 = new Task($id, $description2, $date_due2, $time_due2, $category_id);
     $test_task2->save();
     Task::deleteAll();
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 6
0
$password = '******';
$DB = new PDO($server, $username, $password);
$app->register(new Silex\Provider\TwigServiceProvider(), array('twig.path' => __DIR__ . '/../views'));
$app->get("/", function () use($app) {
    return $app['twig']->render('index.html.twig');
});
$app->get("/tasks", function () use($app) {
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
$app->get("/categories", function () use($app) {
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/tasks", function () use($app) {
    $task = new task($_POST['description']);
    $task->save();
    return $app['twig']->render('tasks.html.twig', array('tasks' => Task::getAll()));
});
$app->post("/delete_tasks", function () use($app) {
    Task::deleteAll();
    return $app['twig']->render('index.html.twig');
});
$app->post("/categories", function () use($app) {
    $category = new Category($_POST['name']);
    $category->save();
    return $app['twig']->render('categories.html.twig', array('categories' => Category::getAll()));
});
$app->post("/delete_categories", function () use($app) {
    Category::deleteAll();
    return $app['twig']->render('index.html.twig');
});
return $app;
Ejemplo n.º 7
0
 protected function tearDown()
 {
     Category::deleteAll();
     Task::deleteAll();
 }
Ejemplo n.º 8
0
 function testDeleteAll()
 {
     //arrange
     $description = "Wash the dog";
     $id = 1;
     $test_task = new Task($description, $id);
     $test_task->save();
     $description2 = "Water the lawn";
     $id2 = 2;
     $test_task2 = new Task($description2, $id);
     $test_task2->save();
     //act
     Task::deleteAll();
     //assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 9
0
 /**
  * @depends testUnprivilegedUserViewUpdateDeleteTasks
  */
 public function testBasicSearchTasks()
 {
     $super = User::getByUsername('super');
     Yii::app()->user->userModel = $super;
     Task::deleteAll();
     $anotherUser = User::getByUsername('steven');
     $authenticationData = $this->login();
     $headers = array('Accept: application/json', 'ZURMO_SESSION_ID: ' . $authenticationData['sessionId'], 'ZURMO_TOKEN: ' . $authenticationData['token'], 'ZURMO_API_REQUEST_TYPE: REST');
     $firstAccount = AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('First Account', 'Customer', 'Automotive', $super);
     $secondAccount = AccountTestHelper::createAccountByNameTypeAndIndustryForOwner('Second Account', 'Customer', 'Automotive', $super);
     TaskTestHelper::createTaskWithOwnerAndRelatedAccount('First Task', $super, $firstAccount);
     TaskTestHelper::createTaskWithOwnerAndRelatedAccount('Second Task', $super, $firstAccount);
     TaskTestHelper::createTaskWithOwnerAndRelatedAccount('Third Task', $super, $secondAccount);
     TaskTestHelper::createTaskWithOwnerAndRelatedAccount('Forth Task', $anotherUser, $secondAccount);
     TaskTestHelper::createTaskWithOwnerAndRelatedAccount('Fifth Task', $super, $firstAccount);
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('name' => ''), 'sort' => 'name');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Fifth Task', $response['data']['items'][0]['name']);
     $this->assertEquals('First Task', $response['data']['items'][1]['name']);
     $this->assertEquals('Forth Task', $response['data']['items'][2]['name']);
     // Second page
     $searchParams['pagination']['page'] = 2;
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(2, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(2, $response['data']['currentPage']);
     $this->assertEquals('Second Task', $response['data']['items'][0]['name']);
     $this->assertEquals('Third Task', $response['data']['items'][1]['name']);
     // Search by name
     $searchParams['pagination']['page'] = 1;
     $searchParams['search']['name'] = 'First Task';
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(1, count($response['data']['items']));
     $this->assertEquals(1, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('First Task', $response['data']['items'][0]['name']);
     // No results
     $searchParams['pagination']['page'] = 1;
     $searchParams['search']['name'] = 'First Task 2';
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(0, $response['data']['totalCount']);
     $this->assertFalse(isset($response['data']['items']));
     // Search by name desc.
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('name' => ''), 'sort' => 'name.desc');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Third Task', $response['data']['items'][0]['name']);
     $this->assertEquals('Second Task', $response['data']['items'][1]['name']);
     $this->assertEquals('Forth Task', $response['data']['items'][2]['name']);
     // Second page
     $searchParams['pagination']['page'] = 2;
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(2, count($response['data']['items']));
     $this->assertEquals(5, $response['data']['totalCount']);
     $this->assertEquals(2, $response['data']['currentPage']);
     $this->assertEquals('First Task', $response['data']['items'][0]['name']);
     $this->assertEquals('Fifth Task', $response['data']['items'][1]['name']);
     // Search by owner, order by name desc
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('owner' => array('id' => $super->id)), 'sort' => 'name.desc');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(4, $response['data']['totalCount']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Third Task', $response['data']['items'][0]['name']);
     $this->assertEquals('Second Task', $response['data']['items'][1]['name']);
     $this->assertEquals('First Task', $response['data']['items'][2]['name']);
     // Second page
     $searchParams['pagination']['page'] = 2;
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(1, count($response['data']['items']));
     $this->assertEquals(4, $response['data']['totalCount']);
     $this->assertEquals(2, $response['data']['currentPage']);
     $this->assertEquals('Fifth Task', $response['data']['items'][0]['name']);
     // Search by account, order by name desc
     $searchParams = array('pagination' => array('page' => 1, 'pageSize' => 3), 'search' => array('activityItems' => array('id' => $firstAccount->getClassId('Item'))), 'sort' => 'name.desc');
     $searchParamsQuery = http_build_query($searchParams);
     $response = $this->createApiCallWithRelativeUrl('list/filter/' . $searchParamsQuery, 'GET', $headers);
     $response = json_decode($response, true);
     $this->assertEquals(ApiResponse::STATUS_SUCCESS, $response['status']);
     $this->assertEquals(3, $response['data']['totalCount']);
     $this->assertEquals(3, count($response['data']['items']));
     $this->assertEquals(1, $response['data']['currentPage']);
     $this->assertEquals('Second Task', $response['data']['items'][0]['name']);
     $this->assertEquals('First Task', $response['data']['items'][1]['name']);
     $this->assertEquals('Fifth Task', $response['data']['items'][2]['name']);
 }
Ejemplo n.º 10
0
 function testDeleteAll()
 {
     //Arrange
     $description = "Wash the dog";
     $id = 1;
     $due_date = null;
     $completed = 0;
     $test_task = new Task($description, $id, $completed, $due_date);
     $test_task->save();
     $description2 = "Water the lawn";
     $id2 = 2;
     $due_date2 = null;
     $completed2 = 0;
     $test_task2 = new Task($description2, $id2, $completed2, $due_date2);
     $test_task2->save();
     //Act
     Task::deleteAll();
     //Assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 11
0
 function test_deleteAll()
 {
     //Arrange
     $due_date = "2015-10-12";
     $description = "Wash the dog";
     $test_task = new Task($description, $due_date, 1);
     $test_task->save();
     //$id2 = 2;
     $description2 = "Water the lawn";
     $test_task2 = new Task($description2, $due_date, 2);
     $test_task2->save();
     //Act
     Task::deleteAll();
     //Assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }
Ejemplo n.º 12
0
 protected function tearDown()
 {
     Task::deleteAll();
 }
Ejemplo n.º 13
0
 function test_deleteAll()
 {
     //Arrange
     $task_name = "Wash the dog";
     $due_date = "2015-08-25";
     $id = 1;
     $test_Task = new Task($task_name, $id, $due_date);
     $test_Task->save();
     $task_name2 = "Water the lawn";
     $due_date2 = "2015-08-22";
     $id2 = 2;
     $test_Task2 = new Task($task_name2, $id2, $due_date2);
     $test_Task2->save();
     //Act
     Task::deleteAll();
     //Assert
     $result = Task::getAll();
     $this->assertEquals([], $result);
 }