@@ -17,7 +17,7 @@ class AttachmentsApiTest extends TestCase
1717 public function test_index_endpoint_returns_expected_book ()
1818 {
1919 $ this ->actingAsApiEditor ();
20- $ page = Page:: query ()-> first ();
20+ $ page = $ this -> entities -> page ();
2121 $ attachment = $ this ->createAttachmentForPage ($ page , [
2222 'name ' => 'My test attachment ' ,
2323 'external ' => true ,
@@ -37,8 +37,7 @@ public function test_index_endpoint_returns_expected_book()
3737 public function test_attachments_listing_based_upon_page_visibility ()
3838 {
3939 $ this ->actingAsApiEditor ();
40- /** @var Page $page */
41- $ page = Page::query ()->first ();
40+ $ page = $ this ->entities ->page ();
4241 $ attachment = $ this ->createAttachmentForPage ($ page , [
4342 'name ' => 'My test attachment ' ,
4443 'external ' => true ,
@@ -66,8 +65,7 @@ public function test_attachments_listing_based_upon_page_visibility()
6665 public function test_create_endpoint_for_link_attachment ()
6766 {
6867 $ this ->actingAsApiAdmin ();
69- /** @var Page $page */
70- $ page = Page::query ()->first ();
68+ $ page = $ this ->entities ->page ();
7169
7270 $ details = [
7371 'name ' => 'My attachment ' ,
@@ -85,8 +83,7 @@ public function test_create_endpoint_for_link_attachment()
8583 public function test_create_endpoint_for_upload_attachment ()
8684 {
8785 $ this ->actingAsApiAdmin ();
88- /** @var Page $page */
89- $ page = Page::query ()->first ();
86+ $ page = $ this ->entities ->page ();
9087 $ file = $ this ->getTestFile ('textfile.txt ' );
9188
9289 $ details = [
@@ -106,8 +103,7 @@ public function test_create_endpoint_for_upload_attachment()
106103 public function test_upload_limit_restricts_attachment_uploads ()
107104 {
108105 $ this ->actingAsApiAdmin ();
109- /** @var Page $page */
110- $ page = Page::query ()->first ();
106+ $ page = $ this ->entities ->page ();
111107
112108 config ()->set ('app.upload_limit ' , 1 );
113109
@@ -130,8 +126,7 @@ public function test_upload_limit_restricts_attachment_uploads()
130126 public function test_name_needed_to_create ()
131127 {
132128 $ this ->actingAsApiAdmin ();
133- /** @var Page $page */
134- $ page = Page::query ()->first ();
129+ $ page = $ this ->entities ->page ();
135130
136131 $ details = [
137132 'uploaded_to ' => $ page ->id ,
@@ -146,8 +141,7 @@ public function test_name_needed_to_create()
146141 public function test_link_or_file_needed_to_create ()
147142 {
148143 $ this ->actingAsApiAdmin ();
149- /** @var Page $page */
150- $ page = Page::query ()->first ();
144+ $ page = $ this ->entities ->page ();
151145
152146 $ details = [
153147 'name ' => 'my attachment ' ,
@@ -165,8 +159,7 @@ public function test_link_or_file_needed_to_create()
165159 public function test_message_shown_if_file_is_not_a_valid_file ()
166160 {
167161 $ this ->actingAsApiAdmin ();
168- /** @var Page $page */
169- $ page = Page::query ()->first ();
162+ $ page = $ this ->entities ->page ();
170163
171164 $ details = [
172165 'name ' => 'my attachment ' ,
@@ -182,8 +175,7 @@ public function test_message_shown_if_file_is_not_a_valid_file()
182175 public function test_read_endpoint_for_link_attachment ()
183176 {
184177 $ this ->actingAsApiAdmin ();
185- /** @var Page $page */
186- $ page = Page::query ()->first ();
178+ $ page = $ this ->entities ->page ();
187179
188180 $ attachment = $ this ->createAttachmentForPage ($ page , [
189181 'name ' => 'my attachment ' ,
@@ -216,8 +208,7 @@ public function test_read_endpoint_for_link_attachment()
216208 public function test_read_endpoint_for_file_attachment ()
217209 {
218210 $ this ->actingAsApiAdmin ();
219- /** @var Page $page */
220- $ page = Page::query ()->first ();
211+ $ page = $ this ->entities ->page ();
221212 $ file = $ this ->getTestFile ('textfile.txt ' );
222213
223214 $ details = [
@@ -259,8 +250,7 @@ public function test_attachment_not_visible_on_other_users_draft()
259250 $ this ->actingAsApiAdmin ();
260251 $ editor = $ this ->getEditor ();
261252
262- /** @var Page $page */
263- $ page = Page::query ()->first ();
253+ $ page = $ this ->entities ->page ();
264254 $ page ->draft = true ;
265255 $ page ->owned_by = $ editor ->id ;
266256 $ page ->save ();
@@ -280,8 +270,7 @@ public function test_attachment_not_visible_on_other_users_draft()
280270 public function test_update_endpoint ()
281271 {
282272 $ this ->actingAsApiAdmin ();
283- /** @var Page $page */
284- $ page = Page::query ()->first ();
273+ $ page = $ this ->entities ->page ();
285274 $ attachment = $ this ->createAttachmentForPage ($ page );
286275
287276 $ details = [
@@ -298,8 +287,7 @@ public function test_update_endpoint()
298287 public function test_update_link_attachment_to_file ()
299288 {
300289 $ this ->actingAsApiAdmin ();
301- /** @var Page $page */
302- $ page = Page::query ()->first ();
290+ $ page = $ this ->entities ->page ();
303291 $ attachment = $ this ->createAttachmentForPage ($ page );
304292 $ file = $ this ->getTestFile ('textfile.txt ' );
305293
@@ -318,8 +306,7 @@ public function test_update_link_attachment_to_file()
318306 public function test_update_file_attachment_to_link ()
319307 {
320308 $ this ->actingAsApiAdmin ();
321- /** @var Page $page */
322- $ page = Page::query ()->first ();
309+ $ page = $ this ->entities ->page ();
323310 $ file = $ this ->getTestFile ('textfile.txt ' );
324311 $ this ->call ('POST ' , $ this ->baseEndpoint , ['name ' => 'My file attachment ' , 'uploaded_to ' => $ page ->id ], [], ['file ' => $ file ]);
325312 /** @var Attachment $attachment */
@@ -346,8 +333,7 @@ public function test_update_file_attachment_to_link()
346333 public function test_delete_endpoint ()
347334 {
348335 $ this ->actingAsApiAdmin ();
349- /** @var Page $page */
350- $ page = Page::query ()->first ();
336+ $ page = $ this ->entities ->page ();
351337 $ attachment = $ this ->createAttachmentForPage ($ page );
352338
353339 $ resp = $ this ->deleteJson ("{$ this ->baseEndpoint }/ {$ attachment ->id }" );
0 commit comments