A free open source IT asset/license management system
Adopt PHP attributes in test classes
Shift96241cb67c0c
diff --git a/tests/Feature/Checkouts/Api/AssetCheckoutTest.php b/tests/Feature/Checkouts/Api/AssetCheckoutTest.phpindex f85af9035a..44783aa63c 100644--- a/tests/Feature/Checkouts/Api/AssetCheckoutTest.php+++ b/tests/Feature/Checkouts/Api/AssetCheckoutTest.php@@ -2,6 +2,7 @@namespace Tests\Feature\Checkouts\Api;+use PHPUnit\Framework\Attributes\DataProvider;use App\Events\CheckoutableCheckedOut;use App\Models\Asset;use App\Models\Location;@@ -148,7 +149,7 @@ class AssetCheckoutTest extends TestCase];}- /** @dataProvider checkoutTargets */+ #[DataProvider('checkoutTargets')]public function testAssetCanBeCheckedOut($data){['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data();diff --git a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.phpindex 165c6a4194..99e30fdcbb 100644--- a/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php+++ b/tests/Feature/Checkouts/Ui/AssetCheckoutTest.php@@ -2,6 +2,7 @@namespace Tests\Feature\Checkouts\Ui;+use PHPUnit\Framework\Attributes\DataProvider;use App\Events\CheckoutableCheckedOut;use App\Models\Accessory;use App\Models\Asset;@@ -167,7 +168,7 @@ class AssetCheckoutTest extends TestCase];}- /** @dataProvider checkoutTargets */+ #[DataProvider('checkoutTargets')]public function testAssetCanBeCheckedOut($data){['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data();diff --git a/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.phpindex 4ae415f1ee..449f65c7ab 100644--- a/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php+++ b/tests/Feature/Notifications/Email/EmailNotificationsUponCheckinTest.php@@ -2,6 +2,7 @@namespace Tests\Feature\Notifications\Email;+use PHPUnit\Framework\Attributes\Group;use App\Events\CheckoutableCheckedIn;use App\Models\Asset;use App\Models\User;@@ -9,9 +10,7 @@ use App\Notifications\CheckinAssetNotification;use Illuminate\Support\Facades\Notification;use Tests\TestCase;-/**- * @group notifications- */+#[Group('notifications')]class EmailNotificationsUponCheckinTest extends TestCase{protected function setUp(): voiddiff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.phpindex 29bf06d9dc..d6f3857a9c 100644--- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php+++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckinTest.php@@ -2,6 +2,8 @@namespace Tests\Feature\Notifications\Webhooks;+use PHPUnit\Framework\Attributes\DataProvider;+use PHPUnit\Framework\Attributes\Group;use App\Events\CheckoutableCheckedIn;use App\Models\Accessory;use App\Models\Asset;@@ -16,9 +18,7 @@ use Illuminate\Database\Eloquent\Model;use Illuminate\Support\Facades\Notification;use Tests\TestCase;-/**- * @group notifications- */+#[Group('notifications')]class SlackNotificationsUponCheckinTest extends TestCase{protected function setUp(): void@@ -69,7 +69,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$this->assertNoSlackNotificationSent(CheckinAccessoryNotification::class);}- /** @dataProvider assetCheckInTargets */+ #[DataProvider('assetCheckInTargets')]public function testAssetCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget){$this->settings->enableSlackWebhook();@@ -82,7 +82,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$this->assertSlackNotificationSent(CheckinAssetNotification::class);}- /** @dataProvider assetCheckInTargets */+ #[DataProvider('assetCheckInTargets')]public function testAssetCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget){$this->settings->disableSlackWebhook();@@ -107,7 +107,7 @@ class SlackNotificationsUponCheckinTest extends TestCaseNotification::assertNothingSent();}- /** @dataProvider licenseCheckInTargets */+ #[DataProvider('licenseCheckInTargets')]public function testLicenseCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget){$this->settings->enableSlackWebhook();@@ -120,7 +120,7 @@ class SlackNotificationsUponCheckinTest extends TestCase$this->assertSlackNotificationSent(CheckinLicenseSeatNotification::class);}- /** @dataProvider licenseCheckInTargets */+ #[DataProvider('licenseCheckInTargets')]public function testLicenseCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget){$this->settings->disableSlackWebhook();diff --git a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.phpindex 048448cad7..753c469778 100644--- a/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php+++ b/tests/Feature/Notifications/Webhooks/SlackNotificationsUponCheckoutTest.php@@ -2,6 +2,8 @@namespace Tests\Feature\Notifications\Webhooks;+use PHPUnit\Framework\Attributes\DataProvider;+use PHPUnit\Framework\Attributes\Group;use App\Events\CheckoutableCheckedOut;use App\Models\Accessory;use App\Models\Asset;@@ -18,9 +20,7 @@ use Illuminate\Database\Eloquent\Model;use Illuminate\Support\Facades\Notification;use Tests\TestCase;-/**- * @group notifications- */+#[Group('notifications')]class SlackNotificationsUponCheckoutTest extends TestCase{protected function setUp(): void@@ -71,7 +71,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase$this->assertNoSlackNotificationSent(CheckoutAccessoryNotification::class);}- /** @dataProvider assetCheckoutTargets */+ #[DataProvider('assetCheckoutTargets')]public function testAssetCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget){$this->settings->enableSlackWebhook();@@ -84,7 +84,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase$this->assertSlackNotificationSent(CheckoutAssetNotification::class);}- /** @dataProvider assetCheckoutTargets */+ #[DataProvider('assetCheckoutTargets')]public function testAssetCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget){$this->settings->disableSlackWebhook();@@ -133,7 +133,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase$this->assertNoSlackNotificationSent(CheckoutConsumableNotification::class);}- /** @dataProvider licenseCheckoutTargets */+ #[DataProvider('licenseCheckoutTargets')]public function testLicenseCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget){$this->settings->enableSlackWebhook();@@ -146,7 +146,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase$this->assertSlackNotificationSent(CheckoutLicenseSeatNotification::class);}- /** @dataProvider licenseCheckoutTargets */+ #[DataProvider('licenseCheckoutTargets')]public function testLicenseCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget){$this->settings->disableSlackWebhook();diff --git a/tests/Feature/Settings/ShowSetUpPageTest.php b/tests/Feature/Settings/ShowSetUpPageTest.phpindex 929c41c4ef..196902ac5f 100644--- a/tests/Feature/Settings/ShowSetUpPageTest.php+++ b/tests/Feature/Settings/ShowSetUpPageTest.php@@ -2,6 +2,7 @@namespace Tests\Feature\Settings;+use PHPUnit\Framework\Attributes\DataProvider;use App\Http\Controllers\SettingsController;use Illuminate\Database\Events\QueryExecuted;use Illuminate\Http\Client\ConnectionException;@@ -163,9 +164,7 @@ class ShowSetUpPageTest extends TestCase});}- /**- * @dataProvider willShowErrorWhenDotEnvFileIsAccessibleViaHttpData- */+ #[DataProvider('willShowErrorWhenDotEnvFileIsAccessibleViaHttpData')]public function testWillShowErrorWhenDotEnvFileIsAccessibleViaHttp(int $statusCode): void{$this->preventStrayRequest = false;diff --git a/tests/Unit/CompanyScopingTest.php b/tests/Unit/CompanyScopingTest.phpindex 3923dd9f7d..aefd5dd016 100644--- a/tests/Unit/CompanyScopingTest.php+++ b/tests/Unit/CompanyScopingTest.php@@ -2,6 +2,7 @@namespace Tests\Unit;+use PHPUnit\Framework\Attributes\DataProvider;use App\Models\Accessory;use App\Models\Asset;use App\Models\AssetMaintenance;@@ -27,7 +28,7 @@ class CompanyScopingTest extends TestCase];}- /** @dataProvider models */+ #[DataProvider('models')]public function testCompanyScoping($model){[$companyA, $companyB] = Company::factory()->count(2)->create();diff --git a/tests/Unit/LdapTest.php b/tests/Unit/LdapTest.phpindex 6beb0d2118..65bdbe627c 100644--- a/tests/Unit/LdapTest.php+++ b/tests/Unit/LdapTest.php@@ -2,12 +2,11 @@namespace Tests\Unit;+use PHPUnit\Framework\Attributes\Group;use App\Models\Ldap;use Tests\TestCase;-/**- * @group ldap- */+#[Group('ldap')]class LdapTest extends TestCase{use \phpmock\phpunit\PHPMock;