Skip to content

Commit 0cccb2e

Browse files
committed
add tests for entities which use HasParent
- tests already exist for page entity - add to database and block tests - add raw parent property to stubs within block and database
1 parent 192ae82 commit 0cccb2e

File tree

4 files changed

+41
-25
lines changed

4 files changed

+41
-25
lines changed

tests/EndpointBlocksTest.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,5 +340,11 @@ public function it_retrieves_a_single_block()
340340

341341
$this->assertInstanceOf(Block::class, $block);
342342
$this->assertInstanceOf(Paragraph::class, $block);
343+
$this->assertEquals('a6f8ebe8-d5df-4ffa-b543-bcd54d1c3bad', $block->getId());
344+
$this->assertEquals('paragraph', $block->getType());
345+
$this->assertEquals('This is a paragraph test', $block->getContent()->getPlainText());
346+
347+
$this->assertEquals('page_id', $block->getParentType());
348+
$this->assertEquals('f2939732-f694-4ce2-b613-f28db6ded673', $block->getParentId());
343349
}
344350
}

tests/EndpointDatabasesTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function it_returns_database_entity_with_filled_properties()
102102

103103
$this->assertInstanceOf(Carbon::class, $databaseResult->getCreatedTime());
104104
$this->assertInstanceOf(Carbon::class, $databaseResult->getLastEditedTime());
105+
106+
$this->assertEquals('page_id', $databaseResult->getParentType());
107+
$this->assertEquals('f2939732-f694-4ce2-b613-f28db6ded673', $databaseResult->getParentId());
105108
}
106109

107110
/** @test */

tests/stubs/endpoints/blocks/response_specific_block_200.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,16 @@
66
"has_children": false,
77
"archived": false,
88
"type": "paragraph",
9+
"parent": {
10+
"type": "page_id",
11+
"page_id": "f2939732-f694-4ce2-b613-f28db6ded673"
12+
},
913
"paragraph": {
1014
"text": [
1115
{
1216
"type": "text",
1317
"text": {
14-
"content": "C:\\xampp\\php",
18+
"content": "This is a paragraph test",
1519
"link": null
1620
},
1721
"annotations": {
@@ -22,7 +26,7 @@
2226
"code": false,
2327
"color": "default"
2428
},
25-
"plain_text": "C:\\xampp\\php",
29+
"plain_text": "This is a paragraph test",
2630
"href": null
2731
}
2832
]

tests/stubs/endpoints/databases/response_specific_200.json

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
"id": "668d797c-76fa-4934-9b05-ad288df2d136",
44
"created_time": "2020-03-17T19:10:04.968Z",
55
"last_edited_time": "2020-03-17T21:49:37.913Z",
6+
"parent": {
7+
"type": "page_id",
8+
"page_id": "f2939732-f694-4ce2-b613-f28db6ded673"
9+
},
610
"description": [
711
{
812
"type": "text",
@@ -122,29 +126,28 @@
122126
"id": "Z\\Eh",
123127
"type": "multi_select",
124128
"multi_select": {
125-
"options":
126-
[
127-
{
128-
"id": "d209b920-212c-4040-9d4a-bdf349dd8b2a",
129-
"name": "Duc Loi Market",
130-
"color": "blue"
131-
},
132-
{
133-
"id": "70104074-0f91-467b-9787-00d59e6e1e41",
134-
"name": "Rainbow Grocery",
135-
"color": "gray"
136-
},
137-
{
138-
"id": "e6fd4f04-894d-4fa7-8d8b-e92d08ebb604",
139-
"name": "Nijiya Market",
140-
"color": "purple"
141-
},
142-
{
143-
"id": "6c3867c5-d542-4f84-b6e9-a420c43094e7",
144-
"name": "Gus's Community Market",
145-
"color": "yellow"
146-
}
147-
]
129+
"options": [
130+
{
131+
"id": "d209b920-212c-4040-9d4a-bdf349dd8b2a",
132+
"name": "Duc Loi Market",
133+
"color": "blue"
134+
},
135+
{
136+
"id": "70104074-0f91-467b-9787-00d59e6e1e41",
137+
"name": "Rainbow Grocery",
138+
"color": "gray"
139+
},
140+
{
141+
"id": "e6fd4f04-894d-4fa7-8d8b-e92d08ebb604",
142+
"name": "Nijiya Market",
143+
"color": "purple"
144+
},
145+
{
146+
"id": "6c3867c5-d542-4f84-b6e9-a420c43094e7",
147+
"name": "Gus's Community Market",
148+
"color": "yellow"
149+
}
150+
]
148151
}
149152
},
150153
"+1": {

0 commit comments

Comments
 (0)