Skip to content

A free open source IT asset/license management system

Use laravel v5.5 withCount manual aliases

snipe20d0dce73ec4
diff --git a/tests/api/ApiCategoriesCest.php b/tests/api/ApiCategoriesCest.php
index 2d334449fe..d844f45e99 100644
--- a/tests/api/ApiCategoriesCest.php
+++ b/tests/api/ApiCategoriesCest.php
@@ -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)));
}
diff --git a/tests/api/ApiCompaniesCest.php b/tests/api/ApiCompaniesCest.php
index 9ae03faea0..a6ad1345e7 100644
--- a/tests/api/ApiCompaniesCest.php
+++ b/tests/api/ApiCompaniesCest.php
@@ -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)));
diff --git a/tests/api/ApiLicensesCest.php b/tests/api/ApiLicensesCest.php
index b7aad28290..73037fbdbc 100644
--- a/tests/api/ApiLicensesCest.php
+++ b/tests/api/ApiLicensesCest.php
@@ -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)));
}
diff --git a/tests/api/ApiLocationsCest.php b/tests/api/ApiLocationsCest.php
index 064488e33e..d240cabe1e 100644
--- a/tests/api/ApiLocationsCest.php
+++ b/tests/api/ApiLocationsCest.php
@@ -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)));
}
diff --git a/tests/api/ApiManufacturersCest.php b/tests/api/ApiManufacturersCest.php
index b7c002fde7..a9a8d3da51 100644
--- a/tests/api/ApiManufacturersCest.php
+++ b/tests/api/ApiManufacturersCest.php
@@ -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)));
diff --git a/tests/api/ApiModelsCest.php b/tests/api/ApiModelsCest.php
index 7df79eb0fb..ed068bfeab 100644
--- a/tests/api/ApiModelsCest.php
+++ b/tests/api/ApiModelsCest.php
@@ -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)));
}
diff --git a/tests/api/ApiStatusLabelsCest.php b/tests/api/ApiStatusLabelsCest.php
index 49aac413ae..2a3c7c26ce 100644
--- a/tests/api/ApiStatusLabelsCest.php
+++ b/tests/api/ApiStatusLabelsCest.php
@@ -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)));
}
diff --git a/tests/api/ApiUsersCest.php b/tests/api/ApiUsersCest.php
index b1063acf06..8d8d7629df 100644
--- a/tests/api/ApiUsersCest.php
+++ b/tests/api/ApiUsersCest.php
@@ -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)));
}