Skip to content

Commit feb000e

Browse files
committed
added test for database query empty result
1 parent 155e573 commit feb000e

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

tests/EndpointDatabaseTest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,45 @@ public function it_queries_a_database_with_filter_and_sorting_and_processes_resu
104104
$this->assertEquals("Betty Holberton", $page->getTitle());
105105
}
106106

107+
/** @test */
108+
public function it_queries_a_database_with_filter_and_sorting_and_has_empty_result()
109+
{
110+
// success /v1/databases/DATABASE_DOES_EXIST/query
111+
Http::fake([
112+
'https://api.notion.com/v1/databases/8284f3ff77e24d4a939d19459e4d6bdc/query*'
113+
=> Http::response(
114+
json_decode(file_get_contents("tests/stubs/endpoints/databases/response_query_no_result_200.json"), true),
115+
200,
116+
['Headers']
117+
)
118+
]);
119+
120+
// Let's search for something that doesn't exists
121+
$filters = new Collection();
122+
123+
$filters
124+
->add(
125+
Filter::rawFilter(
126+
"Known for",
127+
[
128+
"multi_select" =>
129+
["contains" => "something that doesn't exists"]
130+
]
131+
)
132+
);
133+
134+
$result = \Notion::database("8284f3ff77e24d4a939d19459e4d6bdc")
135+
->filterBy($filters)
136+
->query();
137+
138+
$this->assertInstanceOf(PageCollection::class, $result);
139+
140+
$resultCollection = $result->asCollection();
141+
142+
$this->assertIsIterable($resultCollection);
143+
$this->assertCount(0, $resultCollection);
144+
}
145+
107146
/** @test */
108147
public function it_throws_a_notion_exception_bad_request()
109148
{
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"object": "list",
3+
"results": [],
4+
"next_cursor": null,
5+
"has_more": false
6+
}

0 commit comments

Comments
 (0)