Adopt PHP attributes in test classes

This commit is contained in:
Shift
2024-08-06 20:25:21 +00:00
parent b680dab5c9
commit 96241cb67c
8 changed files with 26 additions and 26 deletions
@@ -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();
@@ -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();
@@ -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(): void
@@ -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 TestCase
Notification::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();
@@ -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();
+2 -3
View File
@@ -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;
+2 -1
View File
@@ -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();
+2 -3
View File
@@ -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;