aboutsummaryrefslogtreecommitdiffstats
path: root/htdocs/application/controllers/Unittest.php
blob: 3a12be0177007b060713192a76f276c3cc129d2b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/**
 * Class and Function List:
 * Function list:
 * - __construct()
 * - index()
 * Classes list:
 * - Unittest extends CI_Controller
 */

class Unittest extends CI_Controller
{
	
	function __construct() 
	{
		parent::__construct();

		//protection
		
		if ($_SERVER['HTTP_HOST'] != 'stikked') 
		{
			exit;
		}
	}
	
	function index() 
	{
		$this->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'] = '<?php echo "hello world!";';
		$_POST['lang'] = 'php';
		$_POST['title'] = 'hello world';
		$_POST['name'] = 'stikkeduser';
		$pid = $this->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();
	}
}

© 2014-2024 Faster IT GmbH | imprint | privacy policy