public function testTask() { $mock = $this->getMock('stdClass', ['callback']); $mock->expects($this->exactly(1))->method('callback'); $task = new Task('task_name', function () use($mock) { $mock->callback(); }); $context = $this->getMockBuilder('Deployer\\Task\\Context')->disableOriginalConstructor()->getMock(); $task->run($context); $this->assertEquals('task_name', $task->getName()); $task->desc('Task description.'); $this->assertEquals('Task description.', $task->getDescription()); $task->once(); $this->assertTrue($task->isOnce()); $task->onlyOn(['server']); $this->assertEquals(['server' => 0], $task->getOnlyOn()); $this->assertTrue($task->runOnServer('server')); $task->onlyOn([]); $this->assertTrue($task->runOnServer('server')); $task->onlyOn('server'); $this->assertEquals(['server' => 0], $task->getOnlyOn()); $this->assertTrue($task->runOnServer('server')); $task->onlyOn(); $this->assertTrue($task->runOnServer('server')); $task->setPrivate(); $this->assertTrue($task->isPrivate()); }
function test_getDescription() { //Arrange $description = "Wash the dog"; $test_task = new Task($description); $test_task->save(); //Act $result = $test_task->getDescription(); //Assert $this->assertEquals("Wash the dog", $result); }
function test_Update() { //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(); $new_description = "Home stuff"; //Act $test_task->update($new_description); //Assert $this->assertEquals("Home stuff", $test_task->getDescription()); }
function testUpdate() { //Arrange $description = "Wash the dog"; $id = 1; $due_date = '2015-01-01'; $test_task = new Task($description, $due_date, $id); $test_task->save(); $new_description = "Clean the dog"; $new_due_date = '2015-02-01'; //Act $test_task->update($new_description, $new_due_date); //Assert $this->assertEquals("Clean the dog", $test_task->getDescription()); }
function testUpdate() { //Arrange $description = "Wash the dog"; $id = 1; $due_date = null; $completed = 0; $test_task = new Task($description, $id, $completed, $due_date); $test_task->save(); $new_description = "Clean the dog"; //Act $test_task->update($new_description); //Assert $this->assertEquals("Clean the dog", $test_task->getDescription()); }
if ($formattedDeadline !== false) { $formattedDeadline = date("Y-m-d H:i:s", $formattedDeadline); $task->setDeadline($formattedDeadline); } if ($numNeeded != '') { $task->setNumNeeded($numNeeded); } $task->save(); // save uploaded files to database foreach ($_POST['file'] as $stored => $orig) { $stored = Filter::text($stored); $orig = Filter::text($orig); Upload::saveToDatabase($orig, $stored, Upload::TYPE_TASK, $task->getID(), $project->getID()); } // log it $logEvent = new Event(array('event_type_id' => 'create_task', 'project_id' => $project->getID(), 'user_1_id' => Session::getUserID(), 'item_1_id' => $task->getID(), 'data_1' => $task->getTitle(), 'data_2' => $task->getDescription())); $logEvent->save(); // we're done here Session::setMessage('You created a new task.'); $json = array('success' => '1', 'successUrl' => Url::task($task->getID())); echo json_encode($json); } elseif ($action == 'edit') { // flag default is false; assume nothing is modified to start $modified = false; // is title modified? if ($title != $task->getTitle()) { // save changes $oldTitle = $task->getTitle(); $task->setTitle($title); $task->save(); // log it
function testUpdate() { // Arrange $due_date = "2015-10-12"; $description = "Wash the dog"; $test_task = new Task($description, $due_date, 1); $test_task->save(); $new_description = "Clean the dog"; //Act $test_task->update($new_description); //Assert $this->assertEquals("Clean the dog", $test_task->getDescription()); }
/** * @test */ public function shouldCreateNewTask() { $task = new Task('Sample Title', 'Sample Description'); $this->assertEquals('Sample Title', $task->getTitle()); $this->assertEquals('Sample Description', $task->getDescription()); }
require_once __DIR__ . "/../vendor/autoload.php"; require_once __DIR__ . "/../src/Task.php"; session_start(); if (empty($_SESSION['list_of_tasks'])) { $_SESSION['list_of_tasks'] = array(); } $app = new Silex\Application(); $app->get("/", function () { $output = ""; $all_tasks = Task::getAll(); if (!empty($all_tasks)) { $output = $output . "\n <h1>Here's what you need to do</h1>\n "; foreach (Task::getAll() as $task) { $output = $output . "<p>" . $task->getDescription() . "</p>"; } } $output = $output . "\n <form action='/tasks' method='post'>\n <label for='description'>Task Description</label>\n <input id='description' name='description' type='text'>\n\n <button type='submit'>Add Task</button>\n </form>\n "; $output .= "\n <form action ='/delete_tasks' method='post'>\n <button type='submit'>DELETE!</button>\n </form>\n "; return $output; }); $app->post("/tasks", function () { $task = new Task($_POST['description']); $task->save(); return "\n <h1>You made a Task!</h1>\n <p>" . $task->getDescription() . "</p>\n <p><a href='/'> View your list of things to do.</a></p>\n "; }); $app->post("/delete_tasks", function () { Task::deleteAll(); return "\n <h1> ALL DONE!</a1>\n <p><a href='/'>Back to Work!</a></p>\n "; }); return $app;
public function InsertNewTask(Task $task = null) { if ($task == null || !$task instanceof Task) { return null; } $props = array("UserID," => $task->getUserID(), "ProjectID," => $task->getProjectID(), "Title," => $task->getTitle(), "Date," => $task->getDate(), "TargetHours," => $task->getTargetHours(), "ActualHours," => $task->getActualHours(), "Description," => $task->getDescription(), "IsComplete" => $task->getIsComplete()); foreach ($props as $k => $v) { if ($v != null) { if ($k == "IsComplete") { $_props[$k] = "{$v}"; } else { if (gettype($v) == "string") { $_props[$k] = "'" . $v . "', "; } else { $_props[$k] = "{$v}, "; } } } } $this->_dbAdapt->IStatement($this->dbTbl, $_props); $tmp = $this->_dbAdapt->getLnk(); $tmp->query($this->_dbAdapt->getQry()); unset($tmp); return true; }
function test_update() { $description = "Wash the dog"; $id = 1; $due_date = "2000-01-01"; $test_task = new Task($description, $id, $due_date); $test_task->save(); $new_description = "Clean the dog"; $test_task->update($new_description, $due_date, 0); $this->assertEquals("Clean the dog", $test_task->getDescription()); }
function test_update() { //Arrange $description = "Wash the dog"; $due_date = "1234-12-12"; $id = 1; $task = new Task($description, $due_date, $id); $task->save(); $new_description = "Clean the dog"; //Act $task->update($new_description); //Assert $this->assertEquals("Clean the dog", $task->getDescription()); }
function testUpdate() { //Arrange $name = "School stuff"; $id = null; $test_category = new Category($name, $id); $test_category->save(); $description = "Wash the dog"; $category_id = $test_category->getId(); $test_task = new Task($description, $id, $category_id); $test_task->save(); $new_description = "Clean the dog"; //Act $test_task->update($new_description); //Assert $this->assertEquals("Clean the dog", $test_task->getDescription()); }
public function equals(Task $that) { return $this->getTitle() === $that->getTitle() && $this->getDescription() === $that->getDescription(); }