2009-12-16 06:36:35 +01:00
|
|
|
<?php
|
|
|
|
/**
|
2012-03-24 04:38:57 +01:00
|
|
|
* Tests for the core of SilverStripe, such as how the temporary
|
2009-12-16 06:36:35 +01:00
|
|
|
* directory is determined throughout the framework.
|
|
|
|
*
|
2012-04-12 08:02:46 +02:00
|
|
|
* @package framework
|
2009-12-16 06:36:35 +01:00
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class CoreTest extends SapphireTest {
|
|
|
|
|
2009-12-16 06:36:48 +01:00
|
|
|
protected $tempPath;
|
2009-12-16 06:36:35 +01:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2010-10-19 06:52:46 +02:00
|
|
|
$this->tempPath = Director::baseFolder() . '/silverstripe-cache';
|
2009-12-16 06:36:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTempPathInProject() {
|
2009-12-16 06:36:48 +01:00
|
|
|
if(file_exists($this->tempPath)) {
|
2012-09-19 06:10:33 +02:00
|
|
|
$this->assertEquals(getTempFolder(BASE_PATH), $this->tempPath);
|
2009-12-16 06:36:48 +01:00
|
|
|
} else {
|
|
|
|
// A typical Windows location for where sites are stored on IIS
|
2012-04-16 02:18:17 +02:00
|
|
|
$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
|
2010-10-19 06:52:46 +02:00
|
|
|
|
2009-12-16 06:36:48 +01:00
|
|
|
// A typical Mac OS X location for where sites are stored
|
2012-04-16 02:18:17 +02:00
|
|
|
$this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
|
2011-01-26 23:51:08 +01:00
|
|
|
|
2009-12-16 06:36:48 +01:00
|
|
|
// A typical Linux location for where sites are stored
|
2012-04-16 02:18:17 +02:00
|
|
|
$this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), sys_get_temp_dir() . '/silverstripe-cache-var-www-silverstripe-test-project');
|
2009-12-16 06:36:35 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-19 06:52:46 +02:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
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');
|
2010-10-19 06:52:46 +02:00
|
|
|
}
|
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');
|
2010-10-19 06:52:46 +02:00
|
|
|
}
|
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');
|
2010-10-19 06:52:46 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-03-24 04:38:57 +01:00
|
|
|
}
|