Skip to content

Commit

Permalink
stop using assertJsonFragment when there are multiple results (#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbraswell authored Sep 18, 2022
1 parent 04ad859 commit c010c38
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/tests/Feature/GetSearchResultsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -253,11 +253,15 @@ public function testWeekdayIncludeTwo()
$meeting1 = $this->createMeeting(['weekday_tinyint' => 5]);
$meeting2 = $this->createMeeting(['weekday_tinyint' => 3]);
$meeting3 = $this->createMeeting(['weekday_tinyint' => 1]);
$this->get("/client_interface/json/?switcher=GetSearchResults&weekdays[]=6&weekdays[]=4")
$data = collect($this->get("/client_interface/json/?switcher=GetSearchResults&weekdays[]=6&weekdays[]=4")
->assertStatus(200)
->assertJsonCount(2)
->assertJsonFragment(['id_bigint' => strval($meeting1->id_bigint), 'weekday_tinyint' => '6'])
->assertJsonFragment(['id_bigint' => strval($meeting2->id_bigint), 'weekday_tinyint' => '4']);
->json());

$meeting = $data->filter(fn ($meeting) => $meeting['id_bigint'] == $meeting1->id_bigint)->first();
$this->assertEquals('6', $meeting['weekday_tinyint']);
$meeting = $data->filter(fn ($meeting) => $meeting['id_bigint'] == $meeting2->id_bigint)->first();
$this->assertEquals('4', $meeting['weekday_tinyint']);
}

public function testWeekdayExcludeOne()
Expand Down Expand Up @@ -614,19 +618,18 @@ public function testFormatsIncludeTwoOr()
$meeting1 = $this->createMeeting(['formats' => "$format1->shared_id_bigint,$format2->shared_id_bigint"]);
$meeting2 = $this->createMeeting(['formats' => "$format1->shared_id_bigint"]);
$meeting3 = $this->createMeeting();
$this->get("/client_interface/json/?switcher=GetSearchResults&formats[]=$format1->shared_id_bigint&formats[]=$format2->shared_id_bigint&formats_comparison_operator=OR")
$data = collect($this->get("/client_interface/json/?switcher=GetSearchResults&formats[]=$format1->shared_id_bigint&formats[]=$format2->shared_id_bigint&formats_comparison_operator=OR")
->assertStatus(200)
->assertJsonCount(2)
->assertJsonFragment([
'id_bigint' => strval($meeting1->id_bigint),
'format_shared_id_list' => "$format1->shared_id_bigint,$format2->shared_id_bigint",
'formats' => "$format1->key_string,$format2->key_string",
])
->assertJsonFragment([
'id_bigint' => strval($meeting2->id_bigint),
'format_shared_id_list' => "$format1->shared_id_bigint",
'formats' => "$format1->key_string",
]);
->json());

$meeting = $data->filter(fn ($meeting) => $meeting['id_bigint'] == $meeting1->id_bigint)->first();
$this->assertEquals("$format1->shared_id_bigint,$format2->shared_id_bigint", $meeting['format_shared_id_list']);
$this->assertEquals("$format1->key_string,$format2->key_string", $meeting['formats']);

$meeting = $data->filter(fn ($meeting) => $meeting['id_bigint'] == $meeting2->id_bigint)->first();
$this->assertEquals("$format1->shared_id_bigint", $meeting['format_shared_id_list']);
$this->assertEquals("$format1->key_string", $meeting['formats']);
}

public function testFormatsExcludeTwo()
Expand Down

0 comments on commit c010c38

Please sign in to comment.