2009-12-01 11:26:08 +01:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* Tests for the core of sapphire, such as how the temporary
|
|
|
|
* directory is determined throughout the framework.
|
|
|
|
*
|
|
|
|
* @package sapphire
|
|
|
|
* @subpackage tests
|
|
|
|
*/
|
|
|
|
class CoreTest extends SapphireTest {
|
|
|
|
|
2009-12-01 11:42:38 +01:00
|
|
|
protected $tempPath;
|
2009-12-01 11:26:08 +01:00
|
|
|
|
|
|
|
public function setUp() {
|
|
|
|
parent::setUp();
|
2010-10-06 05:44:10 +02:00
|
|
|
$this->tempPath = Director::baseFolder() . '/silverstripe-cache';
|
2009-12-01 11:26:08 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
public function testGetTempPathInProject() {
|
2009-12-01 11:42:38 +01:00
|
|
|
if(file_exists($this->tempPath)) {
|
|
|
|
$this->assertEquals(getTempFolder(), $this->tempPath);
|
|
|
|
} else {
|
|
|
|
// A typical Windows location for where sites are stored on IIS
|
2011-01-26 23:48:29 +01:00
|
|
|
$this->assertEquals(getTempFolder('C:\\inetpub\\wwwroot\\silverstripe-test-project'), getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
|
2010-10-06 05:44:10 +02:00
|
|
|
|
2009-12-01 11:42:38 +01:00
|
|
|
// A typical Mac OS X location for where sites are stored
|
2011-01-26 23:48:29 +01:00
|
|
|
$this->assertEquals(getTempFolder('/Users/joebloggs/Sites/silverstripe-test-project'), getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
|
|
|
|
|
2009-12-01 11:42:38 +01:00
|
|
|
// A typical Linux location for where sites are stored
|
2011-01-26 23:48:29 +01:00
|
|
|
$this->assertEquals(getTempFolder('/var/www/silverstripe-test-project'), getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project');
|
2009-12-01 11:26:08 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-06 05:44:10 +02:00
|
|
|
public function tearDown() {
|
|
|
|
parent::tearDown();
|
2011-01-26 23:48:29 +01:00
|
|
|
if(file_exists(getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project')) {
|
|
|
|
rmdir(getSysTempDir() . '/silverstripe-cacheC--inetpub-wwwroot-silverstripe-test-project');
|
2010-10-06 05:44:10 +02:00
|
|
|
}
|
2011-01-26 23:48:29 +01:00
|
|
|
if(file_exists(getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project')) {
|
|
|
|
rmdir(getSysTempDir() . '/silverstripe-cache-Users-joebloggs-Sites-silverstripe-test-project');
|
2010-10-06 05:44:10 +02:00
|
|
|
}
|
2011-01-26 23:48:29 +01:00
|
|
|
if(file_exists(getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project')) {
|
|
|
|
rmdir(getSysTempDir() . '/silverstripe-cache-var-www-silverstripe-test-project');
|
2010-10-06 05:44:10 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-12-01 11:26:08 +01:00
|
|
|
}
|