|
7 | 7 | use FiveamCode\LaravelNotionApi\Entities\Blocks\Block; |
8 | 8 | use FiveamCode\LaravelNotionApi\Entities\Blocks\BulletedListItem; |
9 | 9 | use FiveamCode\LaravelNotionApi\Entities\Blocks\Embed; |
| 10 | +use FiveamCode\LaravelNotionApi\Entities\Blocks\File; |
10 | 11 | use FiveamCode\LaravelNotionApi\Entities\Blocks\HeadingOne; |
11 | 12 | use FiveamCode\LaravelNotionApi\Entities\Blocks\HeadingThree; |
12 | 13 | use FiveamCode\LaravelNotionApi\Entities\Blocks\HeadingTwo; |
| 14 | +use FiveamCode\LaravelNotionApi\Entities\Blocks\Image; |
13 | 15 | use FiveamCode\LaravelNotionApi\Entities\Blocks\NumberedListItem; |
14 | 16 | use FiveamCode\LaravelNotionApi\Entities\Blocks\Paragraph; |
| 17 | +use FiveamCode\LaravelNotionApi\Entities\Blocks\Pdf; |
15 | 18 | use FiveamCode\LaravelNotionApi\Entities\Blocks\ToDo; |
16 | 19 | use FiveamCode\LaravelNotionApi\Entities\Blocks\Toggle; |
| 20 | +use FiveamCode\LaravelNotionApi\Entities\Blocks\Video; |
17 | 21 | use FiveamCode\LaravelNotionApi\Exceptions\NotionException; |
18 | 22 | use FiveamCode\LaravelNotionApi\Exceptions\HandlingException; |
19 | 23 | use FiveamCode\LaravelNotionApi\Entities\Collections\BlockCollection; |
@@ -100,7 +104,7 @@ public function it_returns_block_collection_with_children_as_correct_instances() |
100 | 104 | $blockChildrenCollection = $blockChildren->asCollection(); |
101 | 105 | $this->assertContainsOnly(Block::class, $blockChildrenCollection); |
102 | 106 | $this->assertIsIterable($blockChildrenCollection); |
103 | | - $this->assertCount(9, $blockChildrenCollection); |
| 107 | + $this->assertCount(13, $blockChildrenCollection); |
104 | 108 |
|
105 | 109 | # check paragraph |
106 | 110 | $blockChild = $blockChildrenCollection[0]; |
@@ -165,6 +169,42 @@ public function it_returns_block_collection_with_children_as_correct_instances() |
165 | 169 | $this->assertFalse($blockChild->hasChildren()); |
166 | 170 | $this->assertEquals('Testcaption', $blockChild->getCaption()->getPlainText()); |
167 | 171 | $this->assertEquals('https://notion.so', $blockChild->getUrl()); |
| 172 | + |
| 173 | + # check image |
| 174 | + $blockChild = $blockChildrenCollection[9]; |
| 175 | + $this->assertInstanceOf(Image::class, $blockChild); |
| 176 | + $this->assertEquals('image', $blockChild->getType()); |
| 177 | + $this->assertFalse($blockChild->hasChildren()); |
| 178 | + $this->assertEquals('test', $blockChild->getCaption()->getPlainText()); |
| 179 | + $this->assertEquals('external', $blockChild->getHostingType()); |
| 180 | + $this->assertEquals('https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb', $blockChild->getUrl()); |
| 181 | + |
| 182 | + # check file |
| 183 | + $blockChild = $blockChildrenCollection[10]; |
| 184 | + $this->assertInstanceOf(File::class, $blockChild); |
| 185 | + $this->assertEquals('file', $blockChild->getType()); |
| 186 | + $this->assertFalse($blockChild->hasChildren()); |
| 187 | + $this->assertEquals('TestCaption', $blockChild->getCaption()->getPlainText()); |
| 188 | + $this->assertEquals('external', $blockChild->getHostingType()); |
| 189 | + $this->assertEquals('https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb', $blockChild->getUrl()); |
| 190 | + |
| 191 | + # check video |
| 192 | + $blockChild = $blockChildrenCollection[11]; |
| 193 | + $this->assertInstanceOf(Video::class, $blockChild); |
| 194 | + $this->assertEquals('video', $blockChild->getType()); |
| 195 | + $this->assertFalse($blockChild->hasChildren()); |
| 196 | + $this->assertEquals('TestCaption', $blockChild->getCaption()->getPlainText()); |
| 197 | + $this->assertEquals('external', $blockChild->getHostingType()); |
| 198 | + $this->assertEquals('https://www.w3schools.com/html/mov_bbb.mp4', $blockChild->getUrl()); |
| 199 | + |
| 200 | + # check pdf |
| 201 | + $blockChild = $blockChildrenCollection[12]; |
| 202 | + $this->assertInstanceOf(Pdf::class, $blockChild); |
| 203 | + $this->assertEquals('pdf', $blockChild->getType()); |
| 204 | + $this->assertFalse($blockChild->hasChildren()); |
| 205 | + $this->assertEquals('TestCaption', $blockChild->getCaption()->getPlainText()); |
| 206 | + $this->assertEquals('external', $blockChild->getHostingType()); |
| 207 | + $this->assertEquals('https://notion.so/testpdf.pdf', $blockChild->getUrl()); |
168 | 208 | } |
169 | 209 |
|
170 | 210 | /** @test */ |
@@ -212,6 +252,9 @@ public function it_returns_parent_block_in_which_new_blocks_have_been_successful |
212 | 252 | $toDo = ToDo::create("New TextBlock"); |
213 | 253 | $toggle = Toggle::create(["New TextBlock"]); |
214 | 254 | $embed = Embed::create("https://5amco.de", "Testcaption"); |
| 255 | + $image = Image::create("https://images.unsplash.com/photo-1593642533144-3d62aa4783ec?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb", "Testcaption"); |
| 256 | + $video = Image::create("https://www.w3schools.com/html/mov_bbb.mp4", "TestCaption"); |
| 257 | + $pdf = Image::create("https://notion.so/testpdf.pdf", "TestCaption"); |
215 | 258 |
|
216 | 259 | $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append($paragraph); |
217 | 260 | $this->assertInstanceOf(Block::class, $parentBlock); |
@@ -240,8 +283,16 @@ public function it_returns_parent_block_in_which_new_blocks_have_been_successful |
240 | 283 | $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append($embed); |
241 | 284 | $this->assertInstanceOf(Block::class, $parentBlock); |
242 | 285 |
|
| 286 | + $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append($image); |
| 287 | + $this->assertInstanceOf(Block::class, $parentBlock); |
| 288 | + |
| 289 | + $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append($video); |
| 290 | + $this->assertInstanceOf(Block::class, $parentBlock); |
| 291 | + |
| 292 | + $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append($pdf); |
| 293 | + $this->assertInstanceOf(Block::class, $parentBlock); |
243 | 294 |
|
244 | | - $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append([$paragraph, $bulletedListItem, $headingOne, $headingTwo, $headingThree, $numberedListItem, $toDo, $toggle, $embed]); |
| 295 | + $parentBlock = Notion::block('1d719dd1-563b-4387-b74f-20da92b827fb')->append([$paragraph, $bulletedListItem, $headingOne, $headingTwo, $headingThree, $numberedListItem, $toDo, $toggle, $embed, $image, $video, $pdf]); |
245 | 296 | $this->assertInstanceOf(Block::class, $parentBlock); |
246 | 297 | } |
247 | 298 | } |
0 commit comments