Implement tests
This commit is contained in:
parent
7275299165
commit
d29f5fa13e
1 changed files with 37 additions and 5 deletions
|
@ -4,6 +4,7 @@ namespace Tests\Feature\CheckoutAcceptances\Ui;
|
||||||
|
|
||||||
use App\Events\CheckoutAccepted;
|
use App\Events\CheckoutAccepted;
|
||||||
use App\Models\CheckoutAcceptance;
|
use App\Models\CheckoutAcceptance;
|
||||||
|
use App\Models\User;
|
||||||
use Illuminate\Support\Facades\Event;
|
use Illuminate\Support\Facades\Event;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
@ -20,12 +21,44 @@ class AssetAcceptanceTest extends TestCase
|
||||||
|
|
||||||
public function testCannotAcceptAssetAlreadyAccepted()
|
public function testCannotAcceptAssetAlreadyAccepted()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
Event::fake([CheckoutAccepted::class]);
|
||||||
|
|
||||||
|
$checkoutAcceptance = CheckoutAcceptance::factory()->accepted()->create();
|
||||||
|
|
||||||
|
$this->assertFalse($checkoutAcceptance->isPending());
|
||||||
|
|
||||||
|
$this->actingAs($checkoutAcceptance->assignedTo)
|
||||||
|
->post(route('account.store-acceptance', $checkoutAcceptance), [
|
||||||
|
'asset_acceptance' => 'accepted',
|
||||||
|
'note' => 'my note',
|
||||||
|
])
|
||||||
|
->assertRedirectToRoute('account.accept')
|
||||||
|
->assertSessionHas('error');
|
||||||
|
|
||||||
|
Event::assertNotDispatched(CheckoutAccepted::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCannotAcceptAssetForAnotherUser()
|
public function testCannotAcceptAssetForAnotherUser()
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
Event::fake([CheckoutAccepted::class]);
|
||||||
|
|
||||||
|
$checkoutAcceptance = CheckoutAcceptance::factory()->pending()->create();
|
||||||
|
|
||||||
|
$this->assertTrue($checkoutAcceptance->isPending());
|
||||||
|
|
||||||
|
$anotherUser = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($anotherUser)
|
||||||
|
->post(route('account.store-acceptance', $checkoutAcceptance), [
|
||||||
|
'asset_acceptance' => 'accepted',
|
||||||
|
'note' => 'my note',
|
||||||
|
])
|
||||||
|
->assertRedirectToRoute('account.accept')
|
||||||
|
->assertSessionHas('error');
|
||||||
|
|
||||||
|
$this->assertTrue($checkoutAcceptance->fresh()->isPending());
|
||||||
|
|
||||||
|
Event::assertNotDispatched(CheckoutAccepted::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testUserCanAcceptAssetCheckout()
|
public function testUserCanAcceptAssetCheckout()
|
||||||
|
@ -41,7 +74,8 @@ class AssetAcceptanceTest extends TestCase
|
||||||
'asset_acceptance' => 'accepted',
|
'asset_acceptance' => 'accepted',
|
||||||
'note' => 'my note',
|
'note' => 'my note',
|
||||||
])
|
])
|
||||||
->assertRedirectToRoute('account.accept');
|
->assertRedirectToRoute('account.accept')
|
||||||
|
->assertSessionHas('success');
|
||||||
|
|
||||||
$this->assertFalse($checkoutAcceptance->fresh()->isPending());
|
$this->assertFalse($checkoutAcceptance->fresh()->isPending());
|
||||||
|
|
||||||
|
@ -52,6 +86,4 @@ class AssetAcceptanceTest extends TestCase
|
||||||
{
|
{
|
||||||
$this->markTestIncomplete();
|
$this->markTestIncomplete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue