Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit a9eda30

Browse files
committed
BUG: refs #0426. Fix failing search test assertions
1 parent d5da44c commit a9eda30

File tree

1 file changed

+24
-15
lines changed

1 file changed

+24
-15
lines changed

core/tests/controllers/SearchControllerTest.php

Lines changed: 24 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public function testIndexAction()
5454

5555
foreach($resp->results as $result)
5656
{
57-
$this->assertTrue($result->resultType == 'user' || $result->resultType == 'folder' || $result->resultType =='item');
57+
$this->assertTrue($result->resultType == 'user' || $result->resultType == 'folder' || $result->resultType == 'item');
5858

5959
switch($result->resultType)
6060
{
@@ -66,6 +66,7 @@ public function testIndexAction()
6666
case 'folder':
6767
$this->assertTrue(is_numeric($result->folder_id));
6868
$this->assertNotEmpty($result->name);
69+
break;
6970
case 'item':
7071
break;
7172
default:
@@ -84,20 +85,28 @@ public function testLiveSearch()
8485

8586
$resp = json_decode($this->getBody());
8687

87-
// Ensure we get item and user results from live search
88-
$this->assertEquals(count($resp), 4);
89-
$this->assertEquals($resp[0]->category, 'Folders');
90-
$this->assertNotEmpty($resp[0]->value);
91-
$this->assertTrue(is_numeric($resp[0]->folderid));
92-
$this->assertEquals($resp[1]->category, 'Folders');
93-
$this->assertNotEmpty($resp[1]->value);
94-
$this->assertTrue(is_numeric($resp[1]->folderid));
95-
$this->assertEquals($resp[2]->category, 'Users');
96-
$this->assertNotEmpty($resp[2]->value);
97-
$this->assertTrue(is_numeric($resp[2]->userid));
98-
$this->assertEquals($resp[3]->category, 'Users');
99-
$this->assertNotEmpty($resp[3]->value);
100-
$this->assertTrue(is_numeric($resp[3]->userid));
88+
// Ensure we get folder and user results from live search
89+
$this->assertTrue(count($resp) >= 4);
90+
foreach($resp as $result)
91+
{
92+
$this->assertTrue($result->category == 'Users' || $result->category == 'Folders' || $result->category == 'Items');
93+
94+
switch($result->category)
95+
{
96+
case 'Users':
97+
$this->assertTrue(is_numeric($result->userid));
98+
$this->assertNotEmpty($result->value);
99+
break;
100+
case 'Folders':
101+
$this->assertTrue(is_numeric($result->folderid));
102+
$this->assertNotEmpty($result->value);
103+
break;
104+
case 'Items':
105+
break;
106+
default:
107+
break;
108+
}
109+
}
101110

102111
// Ensure we get community results from live search
103112
$this->resetAll();

0 commit comments

Comments
 (0)