Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions API/tests/Feature/GroceryItemControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class GroceryItemControllerTest extends TestCase
{
use RefreshDatabase;

public function testStoreGroceryItem()
public function test_store_validGroceryItem_savesItemToDatabase()
{
$user = User::factory()->create();
$shoppingList = ShoppingList::factory()->create(['user_id' => $user->user_id]);
Expand All @@ -35,7 +35,7 @@ public function testStoreGroceryItem()
]);
}

public function testStoreGroceryItemUnauthorized()
public function test_store_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -51,7 +51,7 @@ public function testStoreGroceryItemUnauthorized()
->assertStatus(403);
}

public function testShowGroceryItems()
public function test_show_validShoppingListId_returnsGroceryItems()
{
$user = User::factory()->create();
$shoppingList = ShoppingList::factory()->create(['user_id' => $user->user_id]);
Expand All @@ -73,7 +73,7 @@ public function testShowGroceryItems()
]);
}

public function testShowGroceryItemsUnauthorized()
public function test_show_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -84,7 +84,7 @@ public function testShowGroceryItemsUnauthorized()
->assertStatus(403);
}

public function testUpdateGroceryItem()
public function test_update_validGroceryItem_savesItemToDatabase()
{
$user = User::factory()->create();
$shoppingList = ShoppingList::factory()->create(['user_id' => $user->user_id]);
Expand All @@ -111,7 +111,7 @@ public function testUpdateGroceryItem()
]);
}

public function testUpdateGroceryItemUnauthorized()
public function test_update_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -130,7 +130,7 @@ public function testUpdateGroceryItemUnauthorized()
->assertStatus(403);
}

public function testDeleteGroceryItem()
public function test_delete_validGroceryItemId_deletesItemInDatabase()
{
$user = User::factory()->create();
$shoppingList = ShoppingList::factory()->create(['user_id' => $user->user_id]);
Expand All @@ -144,7 +144,7 @@ public function testDeleteGroceryItem()
$this->assertDatabaseMissing('grocery_items', ['item_id' => $groceryItem->item_id]);
}

public function testDeleteGroceryItemUnauthorized()
public function test_delete_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand Down
16 changes: 10 additions & 6 deletions API/tests/Feature/ListPermissionsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ protected function setUp(): void
parent::setUp();
}

public function testCreateShareLink(): void
public function test_createShareLink_validListId_returnsNewShareLink(): void
{
$user = User::factory()->create();
$list = ShoppingList::factory()->create([
Expand Down Expand Up @@ -49,7 +49,7 @@ public function testCreateShareLink(): void
$this->assertNotNull($sharedLink->expires_at);
}

public function testVerifyShareLinkValid(): void
public function test_verifyShareLinkAndSavePerms_validShareLink_savesPermissionsInDatabase(): void
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -76,7 +76,11 @@ public function testVerifyShareLinkValid(): void
]);
}

public function testCreateShareLinkChainUnauthorized() {
/* Purpose: User A shares list with User B, but User B shouldn't be able to share with
another user because that isn't okay to User A (only User A should be able to create
share links for their lists since they own those lists)
*/
public function test_createShareLink_sharedUserCannotCreateNewShareLink_returns403Error() {
$user = User::factory()->create();
$otherUser = User::factory()->create();
$list = ShoppingList::factory()->create([
Expand Down Expand Up @@ -108,7 +112,7 @@ public function testCreateShareLinkChainUnauthorized() {
]);
}

public function testVerifyShareLinkUpdateAllowedButNotDelete() {
public function test_verifyShareLinkAndSavePerms_updateAllowedButNotDelete_returns403ErrorForDeleteAttempt() {
$user = User::factory()->create();
$otherUser = User::factory()->create();
$list = ShoppingList::factory()->create([
Expand Down Expand Up @@ -178,7 +182,7 @@ public function testVerifyShareLinkUpdateAllowedButNotDelete() {
]);
}

public function testVerifyShareLinkDeleteAllowedButNotUpdate() {
public function test_verifyShareLinkAndSavePerms_deleteAllowedButNotUpdate_returns403ErrorForUpdateAttempt() {
$user = User::factory()->create();
$otherUser = User::factory()->create();
$list = ShoppingList::factory()->create([
Expand Down Expand Up @@ -252,7 +256,7 @@ public function testVerifyShareLinkDeleteAllowedButNotUpdate() {
]);
}

public function testUnauthorizedUserCannotCreateShareLink(): void
public function test_createShareLink_unauthorizedUser_returns403Error(): void
{
$owner = User::factory()->create();
$unauthorizedUser = User::factory()->create();
Expand Down
16 changes: 8 additions & 8 deletions API/tests/Feature/ShoppingListControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ShoppingListControllerTest extends TestCase
// Runs our migrations to set up the in-memory database with all the proper tables
use RefreshDatabase;

public function testCreateShoppingList()
public function test_create_validShoppingListTitle_savesShoppingListToDatabase()
{
// Create an authenticated user
$user = User::factory()->create();
Expand Down Expand Up @@ -44,7 +44,7 @@ public function testCreateShoppingList()
}


public function testGetUserShoppingLists()
public function test_getUserShoppingLists_userHasShoppingList_returnsOwnedShoppingLists()
{
// Create an authenticated user and a shopping list
$user = User::factory()->create();
Expand All @@ -67,7 +67,7 @@ public function testGetUserShoppingLists()
]);
}

public function testGetSpecificShoppingList()
public function test_get_validShoppingListId_returnsShoppingList()
{
// Create an authenticated user and a shopping list
$user = User::factory()->create();
Expand All @@ -90,7 +90,7 @@ public function testGetSpecificShoppingList()
]);
}

public function testGetSpecificShoppingListUnauthorized()
public function test_get_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -101,7 +101,7 @@ public function testGetSpecificShoppingListUnauthorized()
->assertStatus(403);
}

public function testUpdateShoppingList()
public function test_update_validShoppingListId_updatesShoppingListInDatabase()
{
$user = User::factory()->create();
$list = ShoppingList::factory()->create(['user_id' => $user->user_id, 'name' => 'foo']);
Expand All @@ -119,7 +119,7 @@ public function testUpdateShoppingList()
]);
}

public function testUpdateShoppingListUnauthorized()
public function test_update_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand All @@ -132,7 +132,7 @@ public function testUpdateShoppingListUnauthorized()
->assertStatus(403);
}

public function testDeleteShoppingList()
public function test_delete_validShoppingListId_deletesShoppingListInDatabase()
{
// Create an authenticated user and a shopping list
$user = User::factory()->create();
Expand All @@ -155,7 +155,7 @@ public function testDeleteShoppingList()
]);
}

public function testDeleteShoppingListUnauthorized()
public function test_delete_unauthorizedUser_returns403Error()
{
$user = User::factory()->create();
$otherUser = User::factory()->create();
Expand Down