Use laravel v5.5 withCount manual aliases

This commit is contained in:
snipe 2019-05-22 00:50:48 -07:00
parent 144a32b1ca
commit 20d0dce73e
8 changed files with 8 additions and 8 deletions

View file

@ -31,7 +31,7 @@ class ApiCategoriesCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$category = App\Models\Category::withCount('assets','accessories','consumables','components','licenses')
$category = App\Models\Category::withCount('assets as assets_count','accessories as accessories_count','consumables as consumables_count','components as components_count','licenses as licenses_count')
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new CategoriesTransformer)->transformCategory($category)));
}

View file

@ -32,7 +32,7 @@ class ApiCompaniesCest
$response = json_decode($I->grabResponse(), true);
// dd($response);
// sample verify
$company = App\Models\Company::withCount('assets','licenses','accessories','consumables','components','users')
$company = App\Models\Company::withCount('assets as assets_count','licenses as licenses_count','accessories as accessories_count','consumables as consumables_count','components as components_count','users as users_count')
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new CompaniesTransformer)->transformCompany($company)));

View file

@ -31,7 +31,7 @@ class ApiLicensesCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$license = App\Models\License::orderByDesc('created_at')
->withCount('freeSeats')
->withCount('freeSeats as freeSeats_count')
->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new LicensesTransformer)->transformLicense($license)));
}

View file

@ -32,7 +32,7 @@ class ApiLocationsCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$location = App\Models\Location::orderByDesc('created_at')
->withCount('assignedAssets', 'assets', 'users')
->withCount('assignedAssets as assignedAssets_count', 'assets as assets_count', 'users as users_count')
->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new LocationsTransformer)->transformLocation($location)));
}

View file

@ -31,7 +31,7 @@ class ApiManufacturersCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$manufacturer = App\Models\Manufacturer::withCount('assets','accessories','consumables','licenses')
$manufacturer = App\Models\Manufacturer::withCount('assets as assets_count','accessories as accessories_count','consumables as consumables_count','licenses as licenses_count')
->orderByDesc('created_at')->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new ManufacturersTransformer)->transformManufacturer($manufacturer)));

View file

@ -31,7 +31,7 @@ class ApiAssetModelsCest
$response = json_decode($I->grabResponse(), true);
$assetmodel = App\Models\AssetModel::orderByDesc('created_at')
->withCount('assets')->take(10)->get()->shuffle()->first();
->withCount('assets as assets_count')->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new AssetModelsTransformer)->transformAssetModel($assetmodel)));
}

View file

@ -32,7 +32,7 @@ class ApiStatuslabelsCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$statuslabel = App\Models\Statuslabel::orderByDesc('created_at')
->withCount('assets')
->withCount('assets as assets_count')
->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new StatuslabelsTransformer)->transformStatuslabel($statuslabel)));
}

View file

@ -31,7 +31,7 @@ class ApiUsersCest
$response = json_decode($I->grabResponse(), true);
// sample verify
$user = App\Models\User::orderByDesc('created_at')
->withCount('assets', 'licenses', 'accessories', 'consumables')
->withCount('assets as assets_count', 'licenses as licenses_count', 'accessories as accessories_count', 'consumables as consumables_count')
->take(10)->get()->shuffle()->first();
$I->seeResponseContainsJson($I->removeTimestamps((new UsersTransformer)->transformUser($user)));
}