mirror of
https://github.com/silverstripe/silverstripe-textextraction
synced 2024-06-16 01:31:38 +02:00
FIX: Fixed broken test caused by file being modified.
This commit is contained in:
parent
e56bdf5e27
commit
526de4586c
|
@ -6,17 +6,23 @@ class FileTextExtractableTest extends SapphireTest {
|
||||||
);
|
);
|
||||||
|
|
||||||
function testExtractFileAsText() {
|
function testExtractFileAsText() {
|
||||||
|
// Create a copy of the file, as it may be clobbered by the test
|
||||||
|
// ($file->extractFileAsText() calls $file->write)
|
||||||
|
copy(BASE_PATH.'/textextraction/tests/fixtures/test1.html',BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
|
||||||
|
|
||||||
// Use HTML, since the extractor is always available
|
// Use HTML, since the extractor is always available
|
||||||
$file = new File(array(
|
$file = new File(array(
|
||||||
'Name' => 'test1.html',
|
'Name' => 'test1-copy.html',
|
||||||
'Filename' => 'textextraction/tests/fixtures/test1.html'
|
'Filename' => 'textextraction/tests/fixtures/test1-copy.html'
|
||||||
));
|
));
|
||||||
// Don't write file, since it'd rename the file and make it inaccessible for subsequent tests
|
$file->write();
|
||||||
|
|
||||||
$content = $file->extractFileAsText();
|
$content = $file->extractFileAsText();
|
||||||
$this->assertContains('Test Headline', $content);
|
$this->assertContains('Test Headline', $content);
|
||||||
$this->assertContains('Test Text', $content);
|
$this->assertContains('Test Text', $content);
|
||||||
$this->assertEquals($content, $file->FileContentCache);
|
$this->assertEquals($content, $file->FileContentCache);
|
||||||
|
|
||||||
|
if(file_exists(BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html')) unlink(BASE_PATH.'/textextraction/tests/fixtures/test1-copy.html');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user