silverstripe-framework/tests/core/CoreTest.php

58 lines
2.3 KiB
PHP
Raw Normal View History

<?php
/**
* Tests for the core of SilverStripe, such as how the temporary
* directory is determined throughout the framework.
*
* @package framework
* @subpackage tests
*/
class CoreTest extends SapphireTest {
protected $tempPath;
public function setUp() {
parent::setUp();
$this->tempPath = Director::baseFolder() . '/silverstripe-cache';
}
public function testGetTempPathInProject() {
if(file_exists($this->tempPath)) {
$this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath);
} else {
$user = getTempFolderUsername();
// A typical Windows location for where sites are stored on IIS
2013-08-21 11:27:16 +02:00
$this->assertEquals(sys_get_temp_dir() .
'/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project/' . $user,
getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'));
// A typical Mac OS X location for where sites are stored
2013-08-21 11:27:16 +02:00
$this->assertEquals(sys_get_temp_dir() .
'/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project/' . $user,
getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'));
// A typical Linux location for where sites are stored
$this->assertEquals(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project/' . $user,
getTempFolder('/var/www/silverstripe-test-project'));
}
}
public function tearDown() {
parent::tearDown();
$user = getTempFolderUsername();
2012-04-16 02:18:17 +02:00
if(file_exists(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project')) {
rmdir(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project/' . $user);
2012-04-16 02:18:17 +02:00
rmdir(sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
}
2012-04-16 02:18:17 +02:00
if(file_exists(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project')) {
rmdir(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project/' . $user);
2012-04-16 02:18:17 +02:00
rmdir(sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
}
2012-04-16 02:18:17 +02:00
if(file_exists(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project')) {
rmdir(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project/' . $user);
2012-04-16 02:18:17 +02:00
rmdir(sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
}
}
}