Skip to content

Commit 9ac1588

Browse files
committed
start implementation of tests
1 parent 6a6ba49 commit 9ac1588

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

src/Endpoints/Page.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,18 @@ public function property(string $propertyId): Property|EntityCollection
5151
return new EntityCollection();
5252
}
5353

54-
$type = $rawContent['results'][0]['type'];
54+
$type = $rawContent['type'] ?? $rawContent['results'][0]['type'];
55+
56+
// if($type === 'rollup'){
57+
// dd($rawContent['type']);
58+
// }
59+
// if($)
60+
// dd("HI");
5561

5662
return match ($type) {
5763
'people' => new UserCollection($rawContent),
58-
default => new EntityCollection($rawContent)
64+
// 'rollup' => new Collection
65+
default => dd($rawContent) && new EntityCollection($rawContent)
5966
};
6067
}
6168

tests/RecordedEndpointPageTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
use FiveamCode\LaravelNotionApi\Entities\Collections\EntityCollection;
44
use FiveamCode\LaravelNotionApi\Entities\Properties\Property;
5+
use FiveamCode\LaravelNotionApi\Entities\Properties\Rollup;
56
use Illuminate\Support\Facades\Http;
67

78
$httpRecorder = null;
@@ -19,10 +20,23 @@
1920

2021
$propertyKeys = $databaseStructure->getProperties()->map(fn ($o) => $o->getTitle());
2122

23+
// dd($propertyKeys);
24+
25+
expect($propertyKeys)->toBeInstanceOf(\Illuminate\Support\Collection::class);
26+
expect($propertyKeys)->toHaveCount(16);
27+
28+
// dd($propertyKeys);
29+
2230
foreach ($propertyKeys as $propertyKey) {
2331
$id = $databaseStructure->getProperty($propertyKey)->getId();
2432
$property = \Notion::page('f1884dca3885460e93f52bf4da7cce8e')->property($id);
2533

34+
match($propertyKey){
35+
'Rollup' => dd($property->asCollection()) && expect($property->asCollection()->first())->toBeInstanceOf(Rollup::class),
36+
// default => throw new \Exception('Unknown property key')
37+
default => null
38+
};
39+
2640
if ($propertyKey == 'Rollup' || $propertyKey == 'Person' || $propertyKey == 'Name') {
2741
expect($property)->toBeInstanceOf(EntityCollection::class);
2842
} else {

0 commit comments

Comments
 (0)