summaryrefslogtreecommitdiffstats
path: root/application/test/tests/test_libraries_tempfile.php
blob: f4c10a22eb535c0bcf70ac81746283a0eed17171 (plain)
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
<?php
/*
 * Copyright 2015 Florian "Bluewind" Pritz <bluewind@server-speed.net>
 *
 * Licensed under AGPLv3
 * (see COPYING for full license text)
 *
 */

namespace test\tests;

class test_libraries_tempfile extends \test\Test {

	public function __construct()
	{
		parent::__construct();
	}

	public function init()
	{
	}

	public function cleanup()
	{
	}

	public function test_destructor_normalCase()
	{
		$t = new \libraries\Tempfile();
		$file = $t->get_file();
		$this->t->is(file_exists($file), true, "file should exist");
		unset($t);
		$this->t->is(file_exists($file), false, "file should no longer exist after destruction of object");
	}

	public function test_destructor_alreadyRemoved()
	{
		$t = new \libraries\Tempfile();
		$file = $t->get_file();
		$this->t->is(file_exists($file), true, "file should exist");
		unlink($file);
		$this->t->is(file_exists($file), false, "file deleted");
		unset($t);
		$this->t->is(file_exists($file), false, "file should no longer exist after destruction of object");
	}
}