public function testASortPersistent() { $ts = new TodosEx(); $ts->loadFromFile('todo.txt'); $file = tempnam(sys_get_temp_dir(), 'otodo'); $ts->asort(array('done' => true, 'due' => true, 'priority' => false, 'text' => false)); $ts->saveToFile($file); $this->assertEquals(sha1_file('todo.txt'), sha1_file($file)); unlink($file); }
public function archive($archive) { if (!file_exists($archive)) { touch($archive); } $ta = new TodosEx(); $ta->loadFromFile($archive); $unset = array(); foreach ($this->todos as $k => $todo) { if ($todo->done) { $ta[] = $todo; $unset[] = $k; } } if (count($unset)) { foreach ($unset as $k) { unset($this->todos[$k]); } $ta->saveToFile($archive); return count($unset); } else { return 0; } }