mirror of
https://github.com/snipe/snipe-it.git
synced 2025-03-05 20:52:15 -08:00
And more tests
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
ddf45c5ee9
commit
eceaa72781
|
@ -3,6 +3,7 @@
|
||||||
namespace Tests\Feature\Checkouts\Ui;
|
namespace Tests\Feature\Checkouts\Ui;
|
||||||
|
|
||||||
use App\Events\CheckoutableCheckedOut;
|
use App\Events\CheckoutableCheckedOut;
|
||||||
|
use App\Models\Accessory;
|
||||||
use App\Models\Asset;
|
use App\Models\Asset;
|
||||||
use App\Models\Company;
|
use App\Models\Company;
|
||||||
use App\Models\LicenseSeat;
|
use App\Models\LicenseSeat;
|
||||||
|
@ -251,20 +252,85 @@ class AssetCheckoutTest extends TestCase
|
||||||
->assertRedirect(route('hardware.show',['hardware' => $asset->id]));
|
->assertRedirect(route('hardware.show',['hardware' => $asset->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testAssetCheckoutPagePostIsRedirectedIfModelIsInvalid()
|
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsIndex()
|
||||||
{
|
{
|
||||||
$asset = Asset::factory()->create();
|
$asset = Asset::factory()->create();
|
||||||
$asset->model_id = 0;
|
|
||||||
$asset->forceSave();
|
|
||||||
$user = User::factory()->create();
|
|
||||||
|
|
||||||
$this->actingAs(User::factory()->admin()->create())
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->from(route('hardware.checkout.create', $asset))
|
||||||
->post(route('hardware.checkout.store', $asset), [
|
->post(route('hardware.checkout.store', $asset), [
|
||||||
'checkout_to_type' => 'user',
|
'checkout_to_type' => 'user',
|
||||||
'assigned_user' => $user->id,
|
'assigned_user' => User::factory()->create()->id,
|
||||||
|
'redirect_option' => 'index',
|
||||||
])
|
])
|
||||||
->assertStatus(302)
|
->assertStatus(302)
|
||||||
->assertSessionHas('error')
|
->assertRedirect(route('hardware.index'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsItem()
|
||||||
|
{
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->from(route('hardware.checkout.create', $asset))
|
||||||
|
->post(route('hardware.checkout.store' , $asset), [
|
||||||
|
'checkout_to_type' => 'user',
|
||||||
|
'assigned_user' => User::factory()->create()->id,
|
||||||
|
'redirect_option' => 'item',
|
||||||
|
])
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertSessionHasNoErrors()
|
||||||
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
->assertRedirect(route('hardware.show', ['hardware' => $asset->id]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsUserTarget()
|
||||||
|
{
|
||||||
|
$user = User::factory()->create();
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->from(route('hardware.checkout.create', $asset))
|
||||||
|
->post(route('hardware.checkout.store' , $asset), [
|
||||||
|
'checkout_to_type' => 'user',
|
||||||
|
'assigned_user' => $user->id,
|
||||||
|
'redirect_option' => 'target',
|
||||||
|
'assigned_qty' => 1,
|
||||||
|
])
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('users.show', ['user' => $user]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsAssetTarget()
|
||||||
|
{
|
||||||
|
$target = Asset::factory()->create();
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->from(route('hardware.checkout.create', $asset))
|
||||||
|
->post(route('hardware.checkout.store' , $asset), [
|
||||||
|
'checkout_to_type' => 'asset',
|
||||||
|
'assigned_asset' => $target->id,
|
||||||
|
'redirect_option' => 'target',
|
||||||
|
'assigned_qty' => 1,
|
||||||
|
])
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('hardware.show', ['hardware' => $target]));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAssetCheckoutPagePostIsRedirectedIfRedirectSelectionIsLocationTarget()
|
||||||
|
{
|
||||||
|
$target = Location::factory()->create();
|
||||||
|
$asset = Asset::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->admin()->create())
|
||||||
|
->from(route('hardware.checkout.create', $asset))
|
||||||
|
->post(route('hardware.checkout.store' , $asset), [
|
||||||
|
'checkout_to_type' => 'location',
|
||||||
|
'assigned_location' => $target->id,
|
||||||
|
'redirect_option' => 'target',
|
||||||
|
'assigned_qty' => 1,
|
||||||
|
])
|
||||||
|
->assertStatus(302)
|
||||||
|
->assertRedirect(route('locations.show', ['location' => $target]));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue