- public function test_standard_user_with_manage_users_permission_can_view_other_profile_images()
- {
- $editor = $this->getEditor();
- $this->giveUserPermissions($editor, ['users-manage']);
-
- $admin = $this->getAdmin();
-
- $this->actingAs($admin);
- $file = $this->getTestProfileImage();
- $this->call('POST', '/images/user/upload', ['uploaded_to' => $admin->id], [], ['file' => $file], []);
-
- $expectedJson = [
- 'name' => 'profile.png',
- 'uploaded_to' => $admin->id,
- 'type' => 'user'
- ];
-
- $this->actingAs($editor);
- $adminImagesGet = $this->get("/images/user/all/0?uploaded_to=" . $admin->id);
- $adminImagesGet->assertStatus(200)->assertJsonFragment($expectedJson);
-
- $allImagesGet = $this->get("/images/user/all/0");
- $allImagesGet->assertStatus(200)->assertJsonFragment($expectedJson);
- }
-
- public function test_standard_user_cant_view_other_profile_images()
- {
- $editor = $this->getEditor();
- $admin = $this->getAdmin();
-
- $this->actingAs($admin);
- $file = $this->getTestProfileImage();
- $this->call('POST', '/images/user/upload', ['uploaded_to' => $admin->id], [], ['file' => $file], []);
-
- $this->actingAs($editor);
- $adminImagesGet = $this->get("/images/user/all/0?uploaded_to=" . $admin->id);
- $adminImagesGet->assertStatus(302);
-
- $allImagesGet = $this->get("/images/user/all/0");
- $allImagesGet->assertStatus(302);
- }
-
- public function test_standard_user_cant_upload_other_profile_images()
- {
- $editor = $this->getEditor();
- $admin = $this->getAdmin();
-
- $this->actingAs($editor);
- $file = $this->getTestProfileImage();
- $upload = $this->call('POST', '/images/user/upload', ['uploaded_to' => $admin->id], [], ['file' => $file], []);
- $upload->assertStatus(302);
-
- $this->assertDatabaseMissing('images', [
- 'type' => 'user',
- 'uploaded_to' => $admin->id,
- ]);
- }
-