mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-24 21:24:13 -08:00
attempt to fix tests p2
This commit is contained in:
parent
dceb8e305f
commit
cdd4fef7df
|
@ -77,7 +77,7 @@ class AccessoryCheckinTest extends TestCase
|
||||||
'',
|
'',
|
||||||
));
|
));
|
||||||
|
|
||||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
Mail::assertNotSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Checkouts\Api;
|
namespace Tests\Feature\Checkouts\Api;
|
||||||
|
|
||||||
|
use App\Mail\CheckoutAccessoryMail;
|
||||||
use App\Models\Accessory;
|
use App\Models\Accessory;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\CheckoutAccessoryNotification;
|
use App\Notifications\CheckoutAccessoryNotification;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Tests\Concerns\TestsPermissionsRequirement;
|
use Tests\Concerns\TestsPermissionsRequirement;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
@ -146,7 +148,7 @@ class AccessoryCheckoutTest extends TestCase implements TestsPermissionsRequirem
|
||||||
|
|
||||||
public function testUserSentNotificationUponCheckout()
|
public function testUserSentNotificationUponCheckout()
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Mail::fake();
|
||||||
|
|
||||||
$accessory = Accessory::factory()->requiringAcceptance()->create();
|
$accessory = Accessory::factory()->requiringAcceptance()->create();
|
||||||
$user = User::factory()->create();
|
$user = User::factory()->create();
|
||||||
|
@ -157,7 +159,9 @@ class AccessoryCheckoutTest extends TestCase implements TestsPermissionsRequirem
|
||||||
'checkout_to_type' => 'user',
|
'checkout_to_type' => 'user',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Notification::assertSentTo($user, CheckoutAccessoryNotification::class);
|
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||||
|
return $mail->hasTo($user) && $mail->contains($accessory);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testActionLogCreatedUponCheckout()
|
public function testActionLogCreatedUponCheckout()
|
||||||
|
|
|
@ -2,10 +2,12 @@
|
||||||
|
|
||||||
namespace Tests\Feature\Checkouts\Api;
|
namespace Tests\Feature\Checkouts\Api;
|
||||||
|
|
||||||
|
use App\Mail\CheckoutConsumableMail;
|
||||||
use App\Models\Actionlog;
|
use App\Models\Actionlog;
|
||||||
use App\Models\Consumable;
|
use App\Models\Consumable;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Notifications\CheckoutConsumableNotification;
|
use App\Notifications\CheckoutConsumableNotification;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -51,7 +53,7 @@ class ConsumableCheckoutTest extends TestCase
|
||||||
|
|
||||||
public function testUserSentNotificationUponCheckout()
|
public function testUserSentNotificationUponCheckout()
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Mail::fake();
|
||||||
|
|
||||||
$consumable = Consumable::factory()->requiringAcceptance()->create();
|
$consumable = Consumable::factory()->requiringAcceptance()->create();
|
||||||
|
|
||||||
|
@ -62,7 +64,7 @@ class ConsumableCheckoutTest extends TestCase
|
||||||
'assigned_to' => $user->id,
|
'assigned_to' => $user->id,
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Notification::assertSentTo($user, CheckoutConsumableNotification::class);
|
Mail::assertSentTo($user, CheckoutConsumableMail::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testActionLogCreatedUponCheckout()
|
public function testActionLogCreatedUponCheckout()
|
||||||
|
|
|
@ -171,7 +171,7 @@ class AccessoryCheckoutTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
Mail::assertSent(CheckoutAccessoryMail::class, function ($mail) use ($accessory, $user) {
|
||||||
return $mail->hasTo($user) && $mail->contains($accessory);
|
return $mail->hasTo($user->email) && $mail->accessory->is($accessory);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,7 +66,7 @@ class ConsumableCheckoutTest extends TestCase
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) {
|
Mail::assertSent(CheckoutConsumableMail::class, function ($mail) use ($consumable, $user) {
|
||||||
return $mail->hasTo($user) && $mail->consumables->contains($consumable);
|
return $mail->hasTo($user->email) && $mail->consumable->is($consumable);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,9 @@ class ImportAssetsTest extends ImportDataTestCase implements TestsPermissionsReq
|
||||||
//Notes is never read.
|
//Notes is never read.
|
||||||
// $this->assertEquals($row['notes'], $newAsset->notes);
|
// $this->assertEquals($row['notes'], $newAsset->notes);
|
||||||
|
|
||||||
Mail::assertSent($assignee, CheckoutAssetMail::class);
|
Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($assignee) {
|
||||||
|
return $mail->hasTo($assignee->email);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#[Test]
|
#[Test]
|
||||||
|
|
|
@ -19,7 +19,7 @@ class EmailNotificationsUponCheckinTest extends TestCase
|
||||||
{
|
{
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
|
||||||
Notification::fake();
|
Mail::fake();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCheckInEmailSentToUserIfSettingEnabled()
|
public function testCheckInEmailSentToUserIfSettingEnabled()
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
namespace Tests\Unit;
|
namespace Tests\Unit;
|
||||||
|
|
||||||
|
use App\Mail\CheckoutAssetMail;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\AssetModel;
|
use App\Models\AssetModel;
|
||||||
use App\Models\Category;
|
use App\Models\Category;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use App\Notifications\CheckoutAssetNotification;
|
use App\Notifications\CheckoutAssetNotification;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Notification;
|
use Illuminate\Support\Facades\Notification;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -29,13 +31,13 @@ class NotificationTest extends TestCase
|
||||||
'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)->format('Y-m-d')
|
'purchase_date' => Carbon::createFromDate(2017, 1, 1)->hour(0)->minute(0)->second(0)->format('Y-m-d')
|
||||||
]);
|
]);
|
||||||
|
|
||||||
Notification::fake();
|
Mail::fake();
|
||||||
$asset->checkOut($user, $admin->id);
|
$asset->checkOut($user, $admin->id);
|
||||||
Notification::assertSentTo($user, CheckoutAssetNotification::class);
|
Mail::assertSent($user, CheckoutAssetMail::class);
|
||||||
}
|
}
|
||||||
public function testDefaultEulaIsSentWhenSetInCategory()
|
public function testDefaultEulaIsSentWhenSetInCategory()
|
||||||
{
|
{
|
||||||
Notification::fake();
|
Mail::fake();
|
||||||
|
|
||||||
$this->settings->setEula('My Custom EULA Text');
|
$this->settings->setEula('My Custom EULA Text');
|
||||||
|
|
||||||
|
@ -51,10 +53,10 @@ class NotificationTest extends TestCase
|
||||||
|
|
||||||
$asset->checkOut($user, User::factory()->superuser()->create()->id);
|
$asset->checkOut($user, User::factory()->superuser()->create()->id);
|
||||||
|
|
||||||
Notification::assertSentTo($user, CheckoutAssetNotification::class, function ($notification) {
|
Mail::assertSent(CheckoutAssetMail::class, function ($mail) use ($user) {
|
||||||
$content = $notification->toMail()->render();
|
return $mail->hasTo($user->email) &&
|
||||||
|
str_contains($mail->render(), 'My Custom EULA Text') &&
|
||||||
return str_contains($content, 'My Custom EULA Text') && !str_contains($content, 'EULA Text that should not be used');
|
!str_contains($mail->render(), 'EULA Text that should not be used');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue