Merge pull request #15232 from marcusmoore/shift-126036
Some checks are pending
Crowdin Action / upload-sources-to-crowdin (push) Waiting to run
Docker images (Alpine) / docker (push) Waiting to run
Docker images / docker (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.1) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.2) (push) Waiting to run
Tests in MySQL / PHP ${{ matrix.php-version }} (8.3) (push) Waiting to run
Tests in SQLite / PHP ${{ matrix.php-version }} (8.1.1) (push) Waiting to run

Updated PHPUnit to v10
This commit is contained in:
snipe 2024-08-08 01:23:07 +01:00 committed by GitHub
commit cc1e356c35
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
12 changed files with 637 additions and 673 deletions

2
.gitignore vendored
View file

@ -68,3 +68,5 @@ _ide_helper_models.php
storage/ldap_client_tls.cert storage/ldap_client_tls.cert
storage/ldap_client_tls.key storage/ldap_client_tls.key
/storage/framework/testing /storage/framework/testing
/.phpunit.cache

View file

@ -52,7 +52,7 @@
"livewire/livewire": "^3.5", "livewire/livewire": "^3.5",
"neitanod/forceutf8": "^2.0", "neitanod/forceutf8": "^2.0",
"nesbot/carbon": "^2.32", "nesbot/carbon": "^2.32",
"nunomaduro/collision": "^6.1", "nunomaduro/collision": "^7.0",
"okvpn/clock-lts": "^1.0", "okvpn/clock-lts": "^1.0",
"onelogin/php-saml": "^3.4", "onelogin/php-saml": "^3.4",
"paragonie/constant_time_encoding": "^2.3", "paragonie/constant_time_encoding": "^2.3",
@ -74,13 +74,13 @@
"ext-exif": "*" "ext-exif": "*"
}, },
"require-dev": { "require-dev": {
"brianium/paratest": "^v6.4.4", "brianium/paratest": "^7.0",
"fakerphp/faker": "^1.16", "fakerphp/faker": "^1.16",
"larastan/larastan": "^2.9", "larastan/larastan": "^2.9",
"mockery/mockery": "^1.4", "mockery/mockery": "^1.4",
"nunomaduro/phpinsights": "^2.7", "nunomaduro/phpinsights": "^2.7",
"php-mock/php-mock-phpunit": "^2.10", "php-mock/php-mock-phpunit": "^2.10",
"phpunit/phpunit": "^9.6.19", "phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.5", "squizlabs/php_codesniffer": "^3.5",
"symfony/css-selector": "^4.4", "symfony/css-selector": "^4.4",
"symfony/dom-crawler": "^4.4", "symfony/dom-crawler": "^4.4",

1218
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -1,21 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false" backupGlobals="false"
backupStaticAttributes="false" backupStaticProperties="false"
bootstrap="bootstrap/autoload.php" bootstrap="bootstrap/autoload.php"
cacheDirectory=".phpunit.cache"
colors="true" colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false"
xsi:noNamespaceSchemaLocation="./vendor/phpunit/phpunit/phpunit.xsd" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
> >
<coverage>
<include>
<directory suffix=".php">app/</directory>
</include>
</coverage>
<testsuites> <testsuites>
<testsuite name="Unit"> <testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory> <directory suffix="Test.php">./tests/Unit</directory>
@ -33,4 +26,9 @@
<env name="SESSION_DRIVER" value="array"/> <env name="SESSION_DRIVER" value="array"/>
<ini name="display_errors" value="true"/> <ini name="display_errors" value="true"/>
</php> </php>
<source>
<include>
<directory suffix=".php">app/</directory>
</include>
</source>
</phpunit> </phpunit>

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Checkouts\Api; namespace Tests\Feature\Checkouts\Api;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Events\CheckoutableCheckedOut; use App\Events\CheckoutableCheckedOut;
use App\Models\Asset; use App\Models\Asset;
use App\Models\Location; use App\Models\Location;
@ -82,7 +83,7 @@ class AssetCheckoutTest extends TestCase
* This data provider contains checkout targets along with the * This data provider contains checkout targets along with the
* asset's expected location after the checkout process. * asset's expected location after the checkout process.
*/ */
public function checkoutTargets(): array public static function checkoutTargets(): array
{ {
return [ return [
'Checkout to User' => [ 'Checkout to User' => [
@ -148,7 +149,7 @@ class AssetCheckoutTest extends TestCase
]; ];
} }
/** @dataProvider checkoutTargets */ #[DataProvider('checkoutTargets')]
public function testAssetCanBeCheckedOut($data) public function testAssetCanBeCheckedOut($data)
{ {
['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data(); ['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data();

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Checkouts\Ui; namespace Tests\Feature\Checkouts\Ui;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Events\CheckoutableCheckedOut; use App\Events\CheckoutableCheckedOut;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Asset; use App\Models\Asset;
@ -121,7 +122,7 @@ class AssetCheckoutTest extends TestCase
* This data provider contains checkout targets along with the * This data provider contains checkout targets along with the
* asset's expected location after the checkout process. * asset's expected location after the checkout process.
*/ */
public function checkoutTargets(): array public static function checkoutTargets(): array
{ {
return [ return [
'User' => [function () { 'User' => [function () {
@ -167,7 +168,7 @@ class AssetCheckoutTest extends TestCase
]; ];
} }
/** @dataProvider checkoutTargets */ #[DataProvider('checkoutTargets')]
public function testAssetCanBeCheckedOut($data) public function testAssetCanBeCheckedOut($data)
{ {
['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data(); ['checkout_type' => $type, 'target' => $target, 'expected_location' => $expectedLocation] = $data();

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Notifications\Email; namespace Tests\Feature\Notifications\Email;
use PHPUnit\Framework\Attributes\Group;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Models\Asset; use App\Models\Asset;
use App\Models\User; use App\Models\User;
@ -9,9 +10,7 @@ use App\Notifications\CheckinAssetNotification;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Tests\TestCase; use Tests\TestCase;
/** #[Group('notifications')]
* @group notifications
*/
class EmailNotificationsUponCheckinTest extends TestCase class EmailNotificationsUponCheckinTest extends TestCase
{ {
protected function setUp(): void protected function setUp(): void

View file

@ -2,6 +2,8 @@
namespace Tests\Feature\Notifications\Webhooks; namespace Tests\Feature\Notifications\Webhooks;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use App\Events\CheckoutableCheckedIn; use App\Events\CheckoutableCheckedIn;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Asset; use App\Models\Asset;
@ -16,9 +18,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Tests\TestCase; use Tests\TestCase;
/** #[Group('notifications')]
* @group notifications
*/
class SlackNotificationsUponCheckinTest extends TestCase class SlackNotificationsUponCheckinTest extends TestCase
{ {
protected function setUp(): void protected function setUp(): void
@ -28,7 +28,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
Notification::fake(); Notification::fake();
} }
public function assetCheckInTargets(): array public static function assetCheckInTargets(): array
{ {
return [ return [
'Asset checked out to user' => [fn() => User::factory()->create()], 'Asset checked out to user' => [fn() => User::factory()->create()],
@ -37,7 +37,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
]; ];
} }
public function licenseCheckInTargets(): array public static function licenseCheckInTargets(): array
{ {
return [ return [
'License checked out to user' => [fn() => User::factory()->create()], 'License checked out to user' => [fn() => User::factory()->create()],
@ -69,7 +69,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
$this->assertNoSlackNotificationSent(CheckinAccessoryNotification::class); $this->assertNoSlackNotificationSent(CheckinAccessoryNotification::class);
} }
/** @dataProvider assetCheckInTargets */ #[DataProvider('assetCheckInTargets')]
public function testAssetCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget) public function testAssetCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{ {
$this->settings->enableSlackWebhook(); $this->settings->enableSlackWebhook();
@ -82,7 +82,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
$this->assertSlackNotificationSent(CheckinAssetNotification::class); $this->assertSlackNotificationSent(CheckinAssetNotification::class);
} }
/** @dataProvider assetCheckInTargets */ #[DataProvider('assetCheckInTargets')]
public function testAssetCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) public function testAssetCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{ {
$this->settings->disableSlackWebhook(); $this->settings->disableSlackWebhook();
@ -107,7 +107,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
Notification::assertNothingSent(); Notification::assertNothingSent();
} }
/** @dataProvider licenseCheckInTargets */ #[DataProvider('licenseCheckInTargets')]
public function testLicenseCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget) public function testLicenseCheckinSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{ {
$this->settings->enableSlackWebhook(); $this->settings->enableSlackWebhook();
@ -120,7 +120,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
$this->assertSlackNotificationSent(CheckinLicenseSeatNotification::class); $this->assertSlackNotificationSent(CheckinLicenseSeatNotification::class);
} }
/** @dataProvider licenseCheckInTargets */ #[DataProvider('licenseCheckInTargets')]
public function testLicenseCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) public function testLicenseCheckinDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{ {
$this->settings->disableSlackWebhook(); $this->settings->disableSlackWebhook();

View file

@ -2,6 +2,8 @@
namespace Tests\Feature\Notifications\Webhooks; namespace Tests\Feature\Notifications\Webhooks;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Group;
use App\Events\CheckoutableCheckedOut; use App\Events\CheckoutableCheckedOut;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Asset; use App\Models\Asset;
@ -18,9 +20,7 @@ use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\Notification; use Illuminate\Support\Facades\Notification;
use Tests\TestCase; use Tests\TestCase;
/** #[Group('notifications')]
* @group notifications
*/
class SlackNotificationsUponCheckoutTest extends TestCase class SlackNotificationsUponCheckoutTest extends TestCase
{ {
protected function setUp(): void protected function setUp(): void
@ -30,7 +30,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
Notification::fake(); Notification::fake();
} }
public function assetCheckoutTargets(): array public static function assetCheckoutTargets(): array
{ {
return [ return [
'Asset checked out to user' => [fn() => User::factory()->create()], 'Asset checked out to user' => [fn() => User::factory()->create()],
@ -39,7 +39,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
]; ];
} }
public function licenseCheckoutTargets(): array public static function licenseCheckoutTargets(): array
{ {
return [ return [
'License checked out to user' => [fn() => User::factory()->create()], 'License checked out to user' => [fn() => User::factory()->create()],
@ -71,7 +71,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
$this->assertNoSlackNotificationSent(CheckoutAccessoryNotification::class); $this->assertNoSlackNotificationSent(CheckoutAccessoryNotification::class);
} }
/** @dataProvider assetCheckoutTargets */ #[DataProvider('assetCheckoutTargets')]
public function testAssetCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget) public function testAssetCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{ {
$this->settings->enableSlackWebhook(); $this->settings->enableSlackWebhook();
@ -84,7 +84,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
$this->assertSlackNotificationSent(CheckoutAssetNotification::class); $this->assertSlackNotificationSent(CheckoutAssetNotification::class);
} }
/** @dataProvider assetCheckoutTargets */ #[DataProvider('assetCheckoutTargets')]
public function testAssetCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) public function testAssetCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{ {
$this->settings->disableSlackWebhook(); $this->settings->disableSlackWebhook();
@ -133,7 +133,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
$this->assertNoSlackNotificationSent(CheckoutConsumableNotification::class); $this->assertNoSlackNotificationSent(CheckoutConsumableNotification::class);
} }
/** @dataProvider licenseCheckoutTargets */ #[DataProvider('licenseCheckoutTargets')]
public function testLicenseCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget) public function testLicenseCheckoutSendsSlackNotificationWhenSettingEnabled($checkoutTarget)
{ {
$this->settings->enableSlackWebhook(); $this->settings->enableSlackWebhook();
@ -146,7 +146,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
$this->assertSlackNotificationSent(CheckoutLicenseSeatNotification::class); $this->assertSlackNotificationSent(CheckoutLicenseSeatNotification::class);
} }
/** @dataProvider licenseCheckoutTargets */ #[DataProvider('licenseCheckoutTargets')]
public function testLicenseCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget) public function testLicenseCheckoutDoesNotSendSlackNotificationWhenSettingDisabled($checkoutTarget)
{ {
$this->settings->disableSlackWebhook(); $this->settings->disableSlackWebhook();

View file

@ -2,6 +2,7 @@
namespace Tests\Feature\Settings; namespace Tests\Feature\Settings;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Http\Controllers\SettingsController; use App\Http\Controllers\SettingsController;
use Illuminate\Database\Events\QueryExecuted; use Illuminate\Database\Events\QueryExecuted;
use Illuminate\Http\Client\ConnectionException; use Illuminate\Http\Client\ConnectionException;
@ -163,9 +164,7 @@ class ShowSetUpPageTest extends TestCase
}); });
} }
/** #[DataProvider('willShowErrorWhenDotEnvFileIsAccessibleViaHttpData')]
* @dataProvider willShowErrorWhenDotEnvFileIsAccessibleViaHttpData
*/
public function testWillShowErrorWhenDotEnvFileIsAccessibleViaHttp(int $statusCode): void public function testWillShowErrorWhenDotEnvFileIsAccessibleViaHttp(int $statusCode): void
{ {
$this->preventStrayRequest = false; $this->preventStrayRequest = false;

View file

@ -2,6 +2,7 @@
namespace Tests\Unit; namespace Tests\Unit;
use PHPUnit\Framework\Attributes\DataProvider;
use App\Models\Accessory; use App\Models\Accessory;
use App\Models\Asset; use App\Models\Asset;
use App\Models\AssetMaintenance; use App\Models\AssetMaintenance;
@ -16,7 +17,7 @@ use Tests\TestCase;
class CompanyScopingTest extends TestCase class CompanyScopingTest extends TestCase
{ {
public function models(): array public static function models(): array
{ {
return [ return [
'Accessories' => [Accessory::class], 'Accessories' => [Accessory::class],
@ -27,7 +28,7 @@ class CompanyScopingTest extends TestCase
]; ];
} }
/** @dataProvider models */ #[DataProvider('models')]
public function testCompanyScoping($model) public function testCompanyScoping($model)
{ {
[$companyA, $companyB] = Company::factory()->count(2)->create(); [$companyA, $companyB] = Company::factory()->count(2)->create();

View file

@ -2,12 +2,11 @@
namespace Tests\Unit; namespace Tests\Unit;
use PHPUnit\Framework\Attributes\Group;
use App\Models\Ldap; use App\Models\Ldap;
use Tests\TestCase; use Tests\TestCase;
/** #[Group('ldap')]
* @group ldap
*/
class LdapTest extends TestCase class LdapTest extends TestCase
{ {
use \phpmock\phpunit\PHPMock; use \phpmock\phpunit\PHPMock;