Skip to content

Commit 2ba355e

Browse files
committed
feat: Support query options when retrieving documents. Fixes #6
1 parent 8adc554 commit 2ba355e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

src/Query.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Query
1212
{
1313
public function documents(array $options = [])
1414
{
15-
$value = $this->apiClient->get($this->uri);
15+
$value = $this->apiClient->get($this->uri . '?' . http_build_query($options));
1616

1717
if (empty($value)) {
1818
return [];

tests/CollectionTest.php

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<?php
2+
3+
namespace Morrislaptop\Firestore\Tests;
4+
5+
class CollectionTest extends TestCase
6+
{
7+
/**
8+
* @var CollectionReference
9+
*/
10+
private $collection;
11+
12+
public function setUp()
13+
{
14+
$this->collection = self::$firestore->collection('test-lists');
15+
}
16+
17+
public function testDocuments()
18+
{
19+
// Arrange.
20+
for ($i = 0; $i < 30; $i++) {
21+
$doc = $this->collection->document(__FUNCTION__ . $i);
22+
$doc->set(['test' => true]);
23+
}
24+
25+
// Act.
26+
$docs = $this->collection->documents(['pageSize' => 100]);
27+
28+
// Assert.
29+
$this->assertSame($docs->size(), 30);
30+
}
31+
}

0 commit comments

Comments
 (0)