|
4 | 4 |
|
5 | 5 | use FiveamCode\LaravelNotionApi\Entities\Page;
|
6 | 6 | use FiveamCode\LaravelNotionApi\Entities\Properties\MultiSelect;
|
| 7 | +use FiveamCode\LaravelNotionApi\Entities\Properties\Number; |
7 | 8 | use FiveamCode\LaravelNotionApi\Entities\Properties\Select;
|
8 | 9 | use FiveamCode\LaravelNotionApi\Entities\Properties\Text;
|
| 10 | +use FiveamCode\LaravelNotionApi\Entities\Properties\Title; |
9 | 11 | use FiveamCode\LaravelNotionApi\Entities\PropertyItems\RichText;
|
10 | 12 | use FiveamCode\LaravelNotionApi\Entities\PropertyItems\SelectItem;
|
11 | 13 | use Illuminate\Support\Facades\Http;
|
@@ -108,4 +110,55 @@ public function it_checks_if_specific_page_property_is_a_valid_text_property()
|
108 | 110 | $this->assertSame("this is a nice Text :-)", $text->getRichText()->getPlainText());
|
109 | 111 | $this->assertCount(2, $text->getRichText()->getRaw());
|
110 | 112 | }
|
| 113 | + |
| 114 | + |
| 115 | + /** @test */ |
| 116 | + public function it_checks_if_specific_page_property_is_a_valid_number_property() |
| 117 | + { |
| 118 | + // successful /v1/pages/PAGE_DOES_EXIST |
| 119 | + Http::fake([ |
| 120 | + 'https://api.notion.com/v1/pages/afd5f6fb-1cbd-41d1-a108-a22ae0d9bac8' |
| 121 | + => Http::response( |
| 122 | + json_decode(file_get_contents('tests/stubs/endpoints/pages/response_specific_200.json'), true), |
| 123 | + 200, |
| 124 | + ['Headers'] |
| 125 | + ) |
| 126 | + ]); |
| 127 | + |
| 128 | + $pageResult = \Notion::pages()->find("afd5f6fb-1cbd-41d1-a108-a22ae0d9bac8"); |
| 129 | + $number = $pageResult->getProperty('NumberProp'); |
| 130 | + |
| 131 | + $this->assertInstanceOf(Page::class, $pageResult); |
| 132 | + |
| 133 | + $this->assertInstanceOf(Number::class, $number); |
| 134 | + $this->assertSame('number', $number->getType()); |
| 135 | + $this->assertSame(">d{N", $number->getId()); |
| 136 | + $this->assertSame(500.0, $number->getNumber()); |
| 137 | + $this->assertSame(500.0, $number->getContent()); |
| 138 | + } |
| 139 | + |
| 140 | + /** @test */ |
| 141 | + public function it_checks_if_specific_page_property_is_a_valid_title_property() |
| 142 | + { |
| 143 | + // successful /v1/pages/PAGE_DOES_EXIST |
| 144 | + Http::fake([ |
| 145 | + 'https://api.notion.com/v1/pages/afd5f6fb-1cbd-41d1-a108-a22ae0d9bac8' |
| 146 | + => Http::response( |
| 147 | + json_decode(file_get_contents('tests/stubs/endpoints/pages/response_specific_200.json'), true), |
| 148 | + 200, |
| 149 | + ['Headers'] |
| 150 | + ) |
| 151 | + ]); |
| 152 | + |
| 153 | + $pageResult = \Notion::pages()->find("afd5f6fb-1cbd-41d1-a108-a22ae0d9bac8"); |
| 154 | + $title = $pageResult->getProperty('Name'); |
| 155 | + |
| 156 | + $this->assertInstanceOf(Page::class, $pageResult); |
| 157 | + $this->assertInstanceOf(Title::class, $title); |
| 158 | + $this->assertSame('title', $title->getType()); |
| 159 | + $this->assertSame("title", $title->getId()); |
| 160 | + $this->assertSame("Notion Is Awesome", $title->getPlainText()); |
| 161 | + $this->assertInstanceOf(RichText::class, $title->getContent()); |
| 162 | + $this->assertSame("Notion Is Awesome", $title->getContent()->getPlainText()); |
| 163 | + } |
111 | 164 | }
|
0 commit comments