|
Revision 33106, 1.1 kB
(checked in by coopers, 2 years ago)
|
added twig and twig-extensions as vendor libs
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
class Twig_Tests_TestCase extends PHPUnit_Framework_TestCase |
|---|
| 4 |
{ |
|---|
| 5 |
protected $tmpDir; |
|---|
| 6 |
|
|---|
| 7 |
public function getTempDir() |
|---|
| 8 |
{ |
|---|
| 9 |
return $this->tmpDir; |
|---|
| 10 |
} |
|---|
| 11 |
|
|---|
| 12 |
function setUp() |
|---|
| 13 |
{ |
|---|
| 14 |
$this->tmpDir = sys_get_temp_dir().'/TwigTests'; |
|---|
| 15 |
if (!file_exists($this->tmpDir)) { |
|---|
| 16 |
@mkdir($this->tmpDir, 0777, true);; |
|---|
| 17 |
} |
|---|
| 18 |
|
|---|
| 19 |
if (!is_writable($this->tmpDir)) { |
|---|
| 20 |
$this->markTestSkipped(sprintf('Unable to run the tests as "%s" is not writable.', $this->tmpDir)); |
|---|
| 21 |
} |
|---|
| 22 |
|
|---|
| 23 |
parent::setUp(); |
|---|
| 24 |
} |
|---|
| 25 |
|
|---|
| 26 |
function tearDown() |
|---|
| 27 |
{ |
|---|
| 28 |
$this->removeDir($this->tmpDir); |
|---|
| 29 |
|
|---|
| 30 |
parent::tearDown(); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
private function removeDir($target) |
|---|
| 34 |
{ |
|---|
| 35 |
$fp = opendir($target); |
|---|
| 36 |
while (false !== $file = readdir($fp)) { |
|---|
| 37 |
if (in_array($file, array('.', '..'))) { |
|---|
| 38 |
continue; |
|---|
| 39 |
} |
|---|
| 40 |
|
|---|
| 41 |
if (is_dir($target.'/'.$file)) { |
|---|
| 42 |
self::removeDir($target.'/'.$file); |
|---|
| 43 |
} else { |
|---|
| 44 |
unlink($target.'/'.$file); |
|---|
| 45 |
} |
|---|
| 46 |
} |
|---|
| 47 |
closedir($fp); |
|---|
| 48 |
rmdir($target); |
|---|
| 49 |
} |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|