mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
MINOR Changed ImageTest to use fixture files located in assets/ folder, the filesystem API doesn't support Folder objects with "sapphire/..." paths, which leads to inconsistent results (from r107272)
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@112561 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
9d227ba2e4
commit
8ed5e18085
@ -9,7 +9,10 @@ class FileLinkTrackingTest extends SapphireTest {
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
$this->logInWithPermission('ADMIN');
|
||||
touch(Director::baseFolder() . '/assets/testscript-test-file.pdf');
|
||||
|
||||
$fh = fopen(Director::baseFolder() . '/assets/testscript-test-file.pdf', "w");
|
||||
fwrite($fh, str_repeat('x',1000000));
|
||||
fclose($fh);
|
||||
}
|
||||
function tearDown() {
|
||||
parent::tearDown();
|
||||
|
@ -4,7 +4,7 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
function testGetTagWithTitle() {
|
||||
$image = $this->objFromFixture('Image', 'imageWithTitle');
|
||||
$expected = '<img src="' . Director::baseUrl() . 'sapphire/tests/model/testimages/test_image.png" alt="This is a image Title" />';
|
||||
$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test_image.png" alt="This is a image Title" />';
|
||||
$actual = $image->getTag();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
@ -12,7 +12,7 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
function testGetTagWithoutTitle() {
|
||||
$image = $this->objFromFixture('Image', 'imageWithoutTitle');
|
||||
$expected = '<img src="' . Director::baseUrl() . 'sapphire/tests/model/testimages/test_image.png" alt="test_image" />';
|
||||
$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test_image.png" alt="test_image" />';
|
||||
$actual = $image->getTag();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
@ -20,10 +20,50 @@ class ImageTest extends SapphireTest {
|
||||
|
||||
function testGetTagWithoutTitleContainingDots() {
|
||||
$image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots');
|
||||
$expected = '<img src="' . Director::baseUrl() . 'sapphire/tests/model/testimages/test.image.with.dots.png" alt="test.image.with.dots" />';
|
||||
$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />';
|
||||
$actual = $image->getTag();
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
if(!file_exists(ASSETS_PATH)) mkdir(ASSETS_PATH);
|
||||
|
||||
/* Create a test folders for each of the fixture references */
|
||||
$folderIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($folderIDs as $folderID) {
|
||||
$folder = DataObject::get_by_id('Folder', $folderID);
|
||||
if(!file_exists(BASE_PATH."/$folder->Filename")) mkdir(BASE_PATH."/$folder->Filename");
|
||||
}
|
||||
|
||||
/* Create a test files for each of the fixture references */
|
||||
$fileIDs = $this->allFixtureIDs('Image');
|
||||
foreach($fileIDs as $fileID) {
|
||||
$file = DataObject::get_by_id('Image', $fileID);
|
||||
$fh = fopen(BASE_PATH."/$file->Filename", "w");
|
||||
fwrite($fh, str_repeat('x',1000000));
|
||||
fclose($fh);
|
||||
}
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
/* Remove the test files that we've created */
|
||||
$fileIDs = $this->allFixtureIDs('Image');
|
||||
foreach($fileIDs as $fileID) {
|
||||
$file = DataObject::get_by_id('Image', $fileID);
|
||||
if($file && file_exists(BASE_PATH."/$file->Filename")) unlink(BASE_PATH."/$file->Filename");
|
||||
}
|
||||
|
||||
/* Remove the test folders that we've crated */
|
||||
$folderIDs = $this->allFixtureIDs('Folder');
|
||||
foreach($folderIDs as $folderID) {
|
||||
$folder = DataObject::get_by_id('Folder', $folderID);
|
||||
if($folder && file_exists(BASE_PATH."/$folder->Filename")) Filesystem::removeFolder(BASE_PATH."/$folder->Filename");
|
||||
}
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,8 +1,14 @@
|
||||
Folder:
|
||||
folder1:
|
||||
Filename: assets/ImageTest
|
||||
Image:
|
||||
imageWithTitle:
|
||||
Title: This is a image Title
|
||||
Filename: sapphire/tests/model/testimages/test_image.png
|
||||
Filename: assets/ImageTest/test_image.png
|
||||
Parent: =>Folder.folder1
|
||||
imageWithoutTitle:
|
||||
Filename: sapphire/tests/model/testimages/test_image.png
|
||||
Filename: assets/ImageTest/test_image.png
|
||||
Parent: =>Folder.folder1
|
||||
imageWithoutTitleContainingDots:
|
||||
Filename: sapphire/tests/model/testimages/test.image.with.dots.png
|
||||
Filename: assets/ImageTest/test.image.with.dots.png
|
||||
Parent: =>Folder.folder1
|
Loading…
x
Reference in New Issue
Block a user