Example #1
0
 public function testClearFiltersAndApplyOthers()
 {
     $project = new ProjectsModel();
     $project->readProjectsFromCsvFile("data/data.csv");
     $project->filterByProperty("Yorkshire LL");
     $project->filterByProperty(2014);
     $project->clearFilters();
     $this->assertEquals($project->getAllProjects(), $project->getFilteredProjects());
     $project->filterByLandlord("Housing Leeds");
     $this->assertEquals(array($this->createProject("Housing Leeds", "Yorkshire LL", 3, 2013, 221, 235), $this->createProject("Housing Leeds", "Yorkshire LL", 2, 2014, 206), $this->createProject("Housing Leeds", "Yorkshire LL", 3, 2012, 238, 240), $this->createProject("Housing Leeds", "Yorkshire LL", 1, 2013, 195, 214), $this->createProject("Housing Leeds", "Yorkshire LL", 3, 2014, 215), $this->createProject("Housing Leeds", "Yorkshire LL", 2, 2012, 226, 231), $this->createProject("Housing Leeds", "Yorkshire LL", 1, 2014, 231), $this->createProject("Housing Leeds", "Yorkshire LL", 4, 2013, 226), $this->createProject("Housing Leeds", "Yorkshire LL", 2, 2013, 198, 214), $this->createProject("Housing Leeds", "Yorkshire LL", 4, 2014, 235), $this->createProject("Housing Leeds", "Yorkshire LL", 4, 2012, 181, 197), $this->createProject("Housing Leeds", "Yorkshire LL", 1, 2012, 201, 209)), $project->getFilteredProjects());
 }
 /**
  *This method loads the projects home page 
  *@param null
  *@return void
  *@throws This method does not throw an error
  */
 public function getIndex()
 {
     //get all projects from the database
     $data['projects'] = ProjectsModel::all();
     //get all tasks
     $data['tasks'] = TasksModel::all();
     //load the view file with this information
     return View::make('home/index', $data);
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     // delete the project information
     $clients = ProjectsModel::find($id);
     $clients->delete();
     // redirect
     Session::flash('success_message', 'Successfully deleted the project!');
     return Redirect::to('projects/all');
 }
 /**
  * Delete project
  * Send id of this project
  * @return boolean
  */
 public function actionDelete()
 {
     $id = NULL;
     if (isset($_POST['id'])) {
         $id = intval($_POST['id']);
     }
     if ($id) {
         if (ProjectsModel::deleteById($id)) {
             $this->answer['ok'] = 1;
             $this->answer['msg'][] = "TODO list was deleted";
             $this->answer['data']['id'] = $id;
         } else {
             $this->answer['msg'][] = "TODO list wasn't deleted";
         }
     }
     echo json_encode($this->answer);
     return TRUE;
 }