Test fixes - reorder assertions and ensure string returned

This commit is contained in:
Daniel Hensby 2017-01-16 14:46:22 +00:00
parent 94c3bc9fa1
commit de7372ad3b
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
3 changed files with 11 additions and 11 deletions

View File

@ -2022,7 +2022,7 @@ class LeftAndMain_TreeNode extends ViewableData {
} }
$classes .= ' ' . $filterClasses; $classes .= ' ' . $filterClasses;
} }
return $classes; return $classes ?: '';
} }
public function getObj() { public function getObj() {

View File

@ -302,6 +302,8 @@ class LeftAndMainTest_Object extends DataObject implements TestOnly {
'Hierarchy' 'Hierarchy'
); );
public function CMSTreeClasses() {} public function CMSTreeClasses() {
return '';
}
} }

View File

@ -22,8 +22,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$cssPath = 'ul.tree li#selector-TestTree-'.$folder1->ID.' li#selector-TestTree-'.$folder1Subfolder1->ID.' a span.item'; $cssPath = 'ul.tree li#selector-TestTree-'.$folder1->ID.' li#selector-TestTree-'.$folder1Subfolder1->ID.' a span.item';
$firstResult = $parser->getBySelector($cssPath); $firstResult = $parser->getBySelector($cssPath);
$this->assertEquals( $this->assertEquals(
(string)$firstResult[0],
$folder1Subfolder1->Name, $folder1Subfolder1->Name,
(string)$firstResult[0],
$folder1Subfolder1->Name.' is found, nested under '.$folder1->Name $folder1Subfolder1->Name.' is found, nested under '.$folder1->Name
); );
@ -31,8 +31,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$cssPath = 'ul.tree li#selector-TestTree-'.$subfolder->ID.' a span.item'; $cssPath = 'ul.tree li#selector-TestTree-'.$subfolder->ID.' a span.item';
$secondResult = $parser->getBySelector($cssPath); $secondResult = $parser->getBySelector($cssPath);
$this->assertEquals( $this->assertEquals(
(string)$secondResult[0],
$subfolder->Name, $subfolder->Name,
(string)$secondResult[0],
$subfolder->Name.' is found at root level' $subfolder->Name.' is found at root level'
); );
@ -40,9 +40,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$folder2 = $this->objFromFixture('Folder','folder2'); $folder2 = $this->objFromFixture('Folder','folder2');
$cssPath = 'ul.tree li#selector-TestTree-'.$folder2->ID.' a span.item'; $cssPath = 'ul.tree li#selector-TestTree-'.$folder2->ID.' a span.item';
$noResult = $parser->getBySelector($cssPath); $noResult = $parser->getBySelector($cssPath);
$this->assertEquals( $this->assertEmpty(
$noResult, $noResult,
array(),
$folder2.' is not found' $folder2.' is not found'
); );
@ -58,8 +57,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$cssPath = 'ul.tree li#selector-TestTree-'.$folder1->ID.' li#selector-TestTree-'.$folder1Subfolder1->ID.' a span.item'; $cssPath = 'ul.tree li#selector-TestTree-'.$folder1->ID.' li#selector-TestTree-'.$folder1Subfolder1->ID.' a span.item';
$firstResult = $parser->getBySelector($cssPath); $firstResult = $parser->getBySelector($cssPath);
$this->assertEquals( $this->assertEquals(
(string)$firstResult[0],
$folder1Subfolder1->Name, $folder1Subfolder1->Name,
(string)$firstResult[0],
$folder1Subfolder1->Name.' is found, nested under '.$folder1->Name $folder1Subfolder1->Name.' is found, nested under '.$folder1->Name
); );
@ -74,8 +73,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$file1->Name.' with ID '.$file1->ID.' is in search results' $file1->Name.' with ID '.$file1->ID.' is in search results'
); );
$this->assertEquals( $this->assertEquals(
(string)$firstResult[0],
$file1->Name, $file1->Name,
(string)$firstResult[0],
$file1->Name.' is found nested under '.$subfolder->Name $file1->Name.' is found nested under '.$subfolder->Name
); );
@ -87,8 +86,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$file2->Name.' with ID '.$file2->ID.' is in search results' $file2->Name.' with ID '.$file2->ID.' is in search results'
); );
$this->assertEquals( $this->assertEquals(
(string)$secondResult[0],
$file2->Name, $file2->Name,
(string)$secondResult[0],
$file2->Name.' is found nested under '.$subfolder->Name $file2->Name.' is found nested under '.$subfolder->Name
); );
@ -96,9 +95,8 @@ class TreeDropdownFieldTest extends SapphireTest {
$file3 = $this->objFromFixture('File','asdf'); $file3 = $this->objFromFixture('File','asdf');
$cssPath = 'ul.tree li#selector-TestTree-'.$file3->ID; $cssPath = 'ul.tree li#selector-TestTree-'.$file3->ID;
$noResult = $parser->getBySelector($cssPath); $noResult = $parser->getBySelector($cssPath);
$this->assertEquals( $this->assertEmpty(
$noResult, $noResult,
array(),
$file3->Name.' is not found' $file3->Name.' is not found'
); );
} }