File tree Expand file tree Collapse file tree 6 files changed +46
-14
lines changed
Expand file tree Collapse file tree 6 files changed +46
-14
lines changed Original file line number Diff line number Diff line change 22
33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
5+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
56use FiveamCode \LaravelNotionApi \Notion ;
67use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
78use FiveamCode \LaravelNotionApi \Entities \Collections \BlockCollection ;
@@ -29,15 +30,11 @@ public function children(): BlockCollection
2930 $ this ->url (Endpoint::BLOCKS . "/ " . $ this ->blockId . "/children " . "? {$ this ->buildPaginationQuery ()}" )
3031 );
3132
32- if ($ response ->failed ())
33- throw NotionException::fromResponse ($ response );
34-
3533 return new BlockCollection ($ response ->json ());
3634 }
3735
3836 public function create (): array
3937 {
40- //toDo
41- throw new \Exception ("not implemented yet " );
38+ throw new HandlingException ("Not implemented " );
4239 }
4340}
Original file line number Diff line number Diff line change 33namespace FiveamCode \LaravelNotionApi \Endpoints ;
44
55use FiveamCode \LaravelNotionApi \Entities \Page ;
6+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
67use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
78
89class Pages extends Endpoint implements EndpointInterface
@@ -22,22 +23,19 @@ public function find(string $pageId): Page
2223 $ this ->url (Endpoint::PAGES . "/ " . $ pageId )
2324 );
2425
25- if ($ response ->failed ())
26- throw NotionException::fromResponse ($ response );
27-
2826 return new Page ($ response ->json ());
2927 }
3028
3129 public function create (): array
3230 {
3331 //toDo
34- throw new \ Exception ( " not implemented yet " );
32+ throw new HandlingException ( " Not implemented " );
3533 }
3634
3735
3836 public function updateProperties (): array
3937 {
4038 //toDo
41- throw new \ Exception ( " not implemented yet " );
39+ throw new HandlingException ( " Not implemented " );
4240 }
4341}
Original file line number Diff line number Diff line change @@ -38,10 +38,6 @@ public function find(string $userId): User
3838 $ this ->url (Endpoint::USERS . "/ " . $ userId )
3939 );
4040
41- if ($ response ->failed ())
42- throw NotionException::fromResponse ($ response );
43-
44-
4541 return new User ($ response ->json ());
4642 }
4743}
Original file line number Diff line number Diff line change 22
33namespace FiveamCode \LaravelNotionApi \Tests ;
44
5+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
56use Illuminate \Support \Facades \Http ;
67use FiveamCode \LaravelNotionApi \Entities \Blocks \Block ;
78use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
@@ -88,4 +89,13 @@ public function it_throws_a_notion_exception_not_found()
8889 \Notion::block ("b55c9c91-384d-452b-81db-d1ef79372b11 " )->children ();
8990 }
9091
92+ /** @test */
93+ public function it_throws_a_handling_exception_not_implemented () {
94+
95+ $ this ->expectException (HandlingException::class);
96+ $ this ->expectExceptionMessage ("Not implemented " );
97+
98+ \Notion::block ("" )->create ();
99+ }
100+
91101}
Original file line number Diff line number Diff line change 44
55use Carbon \Carbon ;
66use FiveamCode \LaravelNotionApi \Entities \Page ;
7+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
78use FiveamCode \LaravelNotionApi \Exceptions \NotionException ;
89use Illuminate \Support \Facades \Http ;
910use Orchestra \Testbench \TestCase ;
@@ -86,4 +87,23 @@ public function it_throws_a_notion_exception_not_found()
8687 \Notion::pages ()->find ("b55c9c91-384d-452b-81db-d1ef79372b79 " );
8788 }
8889
90+
91+ /** @test */
92+ public function it_throws_a_handling_exception_not_implemented_for_create () {
93+
94+ $ this ->expectException (HandlingException::class);
95+ $ this ->expectExceptionMessage ("Not implemented " );
96+
97+ \Notion::pages ()->create ();
98+ }
99+
100+ /** @test */
101+ public function it_throws_a_handling_exception_not_implemented_for_update_properties () {
102+
103+ $ this ->expectException (HandlingException::class);
104+ $ this ->expectExceptionMessage ("Not implemented " );
105+
106+ \Notion::pages ()->updateProperties ();
107+ }
108+
89109}
Original file line number Diff line number Diff line change 22
33namespace FiveamCode \LaravelNotionApi \Tests ;
44
5+ use FiveamCode \LaravelNotionApi \Exceptions \HandlingException ;
56use FiveamCode \LaravelNotionApi \Notion ;
67use Orchestra \Testbench \TestCase ;
78
@@ -37,4 +38,14 @@ public function it_returns_notion_instance_with_set_token_and_connection()
3738 $ this ->assertInstanceOf (Notion::class, $ notion );
3839 $ this ->assertNotEmpty ($ notion ->getConnection ());
3940 }
41+
42+
43+ /** @test */
44+ public function it_throws_a_handling_exception_invalid_version ()
45+ {
46+ $ this ->expectException (HandlingException::class);
47+ $ this ->expectExceptionMessage ("invalid version for notion-api " );
48+
49+ $ notion = new Notion ("secret_* " , "v-does-not-exist " );
50+ }
4051}
You can’t perform that action at this time.
0 commit comments