Permalink
Browse files

BUGFIX: fixed asserts and file cleanup

DataObject::get_one returns false if not found, so better check for
object. Also, the directory would not be cleaned, so on the subsequent
run the files could end up having suffixes.

missed this one
  • Loading branch information...
1 parent a1327fa commit a2c9c409a8d76214a189a054e8996179a905ca91 @mateusz mateusz committed Apr 18, 2012
Showing with 5 additions and 5 deletions.
  1. +5 −5 tests/forms/uploadfield/UploadFieldTest.php
View
10 tests/forms/uploadfield/UploadFieldTest.php
@@ -28,7 +28,7 @@ function testUploadNoRelation() {
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/UploadFieldTest/$tmpFileName");
$uploadedFile = DataObject::get_one('File', sprintf('"Name" = \'%s\'', $tmpFileName));
- $this->assertNotNull($uploadedFile);
+ $this->assertTrue(is_object($uploadedFile), 'The file object is created');
}
function testUploadHasOneRelation() {
@@ -48,7 +48,7 @@ function testUploadHasOneRelation() {
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/UploadFieldTest/$tmpFileName");
$uploadedFile = DataObject::get_one('File', sprintf('"Name" = \'%s\'', $tmpFileName));
- $this->assertNotNull($uploadedFile);
+ $this->assertTrue(is_object($uploadedFile), 'The file object is created');
$record = DataObject::get_by_id($record->class, $record->ID, false);
$this->assertTrue($record->HasOneFile()->exists());
@@ -69,7 +69,7 @@ function testUploadHasManyRelation() {
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/UploadFieldTest/$tmpFileName");
$uploadedFile = DataObject::get_one('File', sprintf('"Name" = \'%s\'', $tmpFileName));
- $this->assertNotNull($uploadedFile);
+ $this->assertTrue(is_object($uploadedFile), 'The file object is created');
$record = DataObject::get_by_id($record->class, $record->ID, false);
$this->assertEquals(3, $record->HasManyFiles()->Count());
@@ -91,7 +91,7 @@ function testUploadManyManyRelation() {
$this->assertFalse($response->isError());
$this->assertFileExists(ASSETS_PATH . "/UploadFieldTest/$tmpFileName");
$uploadedFile = DataObject::get_one('File', sprintf('"Name" = \'%s\'', $tmpFileName));
- $this->assertNotNull($uploadedFile);
+ $this->assertTrue(is_object($uploadedFile), 'The file object is created');
$record = DataObject::get_by_id($record->class, $record->ID, false);
$this->assertEquals($relationCount+1, $record->ManyManyFiles()->Count());
@@ -605,7 +605,7 @@ function tearDown() {
}
// Remove left over folders and any files that may exist
- if(file_exists('../assets/UploadFieldTest')) Filesystem::removeFolder('../assets/FileTest');
+ if(file_exists('../assets/UploadFieldTest')) Filesystem::removeFolder('../assets/UploadFieldTest');
}
}

0 comments on commit a2c9c40

Please sign in to comment.