diff --git a/htdocs/application/controllers/unittest.php b/htdocs/application/controllers/unittest.php new file mode 100755 index 0000000..3a12be0 --- /dev/null +++ b/htdocs/application/controllers/unittest.php @@ -0,0 +1,57 @@ +load->library('unit_test'); + $this->load->model('pastes'); + + //self test + $test = 1 + 1; + $expected_result = 2; + $test_name = 'Self test: Adds one plus one'; + $this->unit->run($test, $expected_result, $test_name); + + //manipulation: create paste + $_POST['code'] = 'pastes->createPaste(); + + //paste created, has pid + $test = $pid; + $expected_result = 'is_string'; + $test_name = 'Create paste, has pid'; + $this->unit->run($test, $expected_result, $test_name); + $pid = str_replace('view/', '', $pid); + + //manipulation: delete paste + $this->pastes->delete_paste($pid); + + //report + echo $this->unit->report(); + } +} diff --git a/htdocs/application/models/pastes.php b/htdocs/application/models/pastes.php index 930796c..85af467 100755 --- a/htdocs/application/models/pastes.php +++ b/htdocs/application/models/pastes.php @@ -15,6 +15,7 @@ * - getTrends() * - getSpamLists() * - cron() + * - delete_paste() * - random_paste() * Classes list: * - Pastes extends CI_Model @@ -490,6 +491,13 @@ class Pastes extends CI_Model return; } + function delete_paste($pid) + { + $this->db->where('pid', $pid); + $this->db->delete('pastes'); + return; + } + function random_paste() { $this->load->library('process');