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.key
/storage/framework/testing
/.phpunit.cache

View file

@ -52,7 +52,7 @@
"livewire/livewire": "^3.5",
"neitanod/forceutf8": "^2.0",
"nesbot/carbon": "^2.32",
"nunomaduro/collision": "^6.1",
"nunomaduro/collision": "^7.0",
"okvpn/clock-lts": "^1.0",
"onelogin/php-saml": "^3.4",
"paragonie/constant_time_encoding": "^2.3",
@ -74,13 +74,13 @@
"ext-exif": "*"
},
"require-dev": {
"brianium/paratest": "^v6.4.4",
"brianium/paratest": "^7.0",
"fakerphp/faker": "^1.16",
"larastan/larastan": "^2.9",
"mockery/mockery": "^1.4",
"nunomaduro/phpinsights": "^2.7",
"php-mock/php-mock-phpunit": "^2.10",
"phpunit/phpunit": "^9.6.19",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.5",
"symfony/css-selector": "^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"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
backupGlobals="false"
backupStaticAttributes="false"
backupStaticProperties="false"
bootstrap="bootstrap/autoload.php"
cacheDirectory=".phpunit.cache"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="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>
<testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory>
@ -33,4 +26,9 @@
<env name="SESSION_DRIVER" value="array"/>
<ini name="display_errors" value="true"/>
</php>
<source>
<include>
<directory suffix=".php">app/</directory>
</include>
</source>
</phpunit>

View file

@ -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;
@ -82,7 +83,7 @@ class AssetCheckoutTest extends TestCase
* This data provider contains checkout targets along with the
* asset's expected location after the checkout process.
*/
public function checkoutTargets(): array
public static function checkoutTargets(): array
{
return [
'Checkout to User' => [
@ -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();

View file

@ -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;
@ -121,7 +122,7 @@ class AssetCheckoutTest extends TestCase
* This data provider contains checkout targets along with the
* asset's expected location after the checkout process.
*/
public function checkoutTargets(): array
public static function checkoutTargets(): array
{
return [
'User' => [function () {
@ -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();

View file

@ -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

View file

@ -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
@ -28,7 +28,7 @@ class SlackNotificationsUponCheckinTest extends TestCase
Notification::fake();
}
public function assetCheckInTargets(): array
public static function assetCheckInTargets(): array
{
return [
'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 [
'License checked out to user' => [fn() => User::factory()->create()],
@ -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();

View file

@ -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
@ -30,7 +30,7 @@ class SlackNotificationsUponCheckoutTest extends TestCase
Notification::fake();
}
public function assetCheckoutTargets(): array
public static function assetCheckoutTargets(): array
{
return [
'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 [
'License checked out to user' => [fn() => User::factory()->create()],
@ -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();

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;

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;
@ -16,7 +17,7 @@ use Tests\TestCase;
class CompanyScopingTest extends TestCase
{
public function models(): array
public static function models(): array
{
return [
'Accessories' => [Accessory::class],
@ -27,7 +28,7 @@ class CompanyScopingTest extends TestCase
];
}
/** @dataProvider models */
#[DataProvider('models')]
public function testCompanyScoping($model)
{
[$companyA, $companyB] = Company::factory()->count(2)->create();

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;