From 1f8c3cc670abe769a67c5d12c9a71652d000427e Mon Sep 17 00:00:00 2001 From: Daniel Meltzer Date: Wed, 29 Apr 2020 11:01:52 -0400 Subject: [PATCH] Test fixes. --- app/Http/Controllers/Api/UsersController.php | 3 ++- tests/api/ApiLicensesCest.php | 3 ++- tests/api/ApiUsersCest.php | 1 + tests/functional/GroupsCest.php | 14 ++------------ tests/unit/AssetTest.php | 5 +++++ 5 files changed, 12 insertions(+), 14 deletions(-) diff --git a/app/Http/Controllers/Api/UsersController.php b/app/Http/Controllers/Api/UsersController.php index 3bc1c9edb0..5f747726c9 100644 --- a/app/Http/Controllers/Api/UsersController.php +++ b/app/Http/Controllers/Api/UsersController.php @@ -14,8 +14,9 @@ use App\Models\Asset; use App\Models\Company; use App\Models\License; use App\Models\User; -use Illuminate\Http\Request; use Auth; +use Illuminate\Http\Request; +use Illuminate\Support\Facades\Storage; class UsersController extends Controller { diff --git a/tests/api/ApiLicensesCest.php b/tests/api/ApiLicensesCest.php index 39073bdf2c..db386d062c 100644 --- a/tests/api/ApiLicensesCest.php +++ b/tests/api/ApiLicensesCest.php @@ -116,7 +116,8 @@ class ApiLicensesCest 'category_id' => $temp_license->category_id, 'termination_date' => $temp_license->termination_date, ]; - + // We aren't checking anyhting out in this test, so this fakes the withCount() that happens on a normal db fetch. + $temp_license->free_seats_count = $temp_license->seats; $I->assertNotEquals($license->name, $data['name']); // update diff --git a/tests/api/ApiUsersCest.php b/tests/api/ApiUsersCest.php index 0fea69e283..1306e81b0f 100644 --- a/tests/api/ApiUsersCest.php +++ b/tests/api/ApiUsersCest.php @@ -65,6 +65,7 @@ class ApiUsersCest 'notes' => $temp_user->notes, 'manager_id' => $temp_user->manager_id, 'password' => $temp_user->password, + 'password_confirmation' => $temp_user->password, 'phone' => $temp_user->phone, 'state' => $temp_user->state, 'username' => $temp_user->username, diff --git a/tests/functional/GroupsCest.php b/tests/functional/GroupsCest.php index 724b4dbca1..dd976d8c00 100644 --- a/tests/functional/GroupsCest.php +++ b/tests/functional/GroupsCest.php @@ -58,10 +58,7 @@ class GroupsCest public function allowsDelete(FunctionalTester $I, $scenario) { - $scenario->incomplete('Fix this test to generate a group for deleting'); - $I->wantTo('Ensure I can delete a group'); - // create a group $I->amOnPage(route('groups.create')); $I->seeResponseCodeIs(200); @@ -70,16 +67,9 @@ class GroupsCest $I->dontSee('<span class="'); $I->seeElement('.alert-success'); - // delete it - $I->amOnPage(route('groups.delete', Group::doesntHave('users')->first()->id)); + $I->sendDelete(route('groups.destroy', Group::whereName('TestGroup')->doesntHave('users')->first()->id)); $I->seeResponseCodeIs(200); $I->seeElement('.alert-success'); - // $I->seeResponseCodeIs(200); - } - - public function allowsEditing(FunctionalTester $I, $scenario) - { - $scenario->incomplete('Fix this test to generate a group for editing'); - $I->wantTo('Ensure i can edit a group'); + $I->seeResponseCodeIs(200); } } diff --git a/tests/unit/AssetTest.php b/tests/unit/AssetTest.php index 375da10f18..d1b5638859 100644 --- a/tests/unit/AssetTest.php +++ b/tests/unit/AssetTest.php @@ -287,6 +287,11 @@ class AssetTest extends BaseTest 'target_id' => $target->id ]); + // An Asset cannot be checked out to itself. + $target = $this->createValidAsset(); + $this->expectException(CheckoutNotAllowed::class); + $target->checkOut($target, $adminUser); + // An Asset Can be checked out to a location, and this should be logged. $target = $this->createValidLocation();