Lint tests
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
15ba95e7e8
commit
8979ddc49d
|
@ -4,6 +4,7 @@ namespace Tests\Feature\Subscription;
|
|||
|
||||
use App\Fee;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\RequestFactories\SubscriptionRequestFactory;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StoreTest extends TestCase
|
||||
|
@ -15,11 +16,10 @@ class StoreTest extends TestCase
|
|||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$fee = Fee::factory()->create();
|
||||
|
||||
$response = $this->from('/subscription')->post('/subscription', [
|
||||
'amount' => 2500,
|
||||
'fee_id' => $fee->id,
|
||||
'name' => 'Lorem',
|
||||
]);
|
||||
$response = $this->from('/subscription')->post(
|
||||
'/subscription',
|
||||
SubscriptionRequestFactory::new()->amount(2500)->fee($fee)->name('lorem')->create()
|
||||
);
|
||||
|
||||
$response->assertRedirect('/subscription');
|
||||
$this->assertDatabaseHas('subscriptions', [
|
||||
|
@ -34,11 +34,10 @@ class StoreTest extends TestCase
|
|||
$this->login()->loginNami();
|
||||
$fee = Fee::factory()->create();
|
||||
|
||||
$response = $this->post('/subscription', [
|
||||
'amount' => '',
|
||||
'fee_id' => 99,
|
||||
'name' => '',
|
||||
]);
|
||||
$response = $this->post(
|
||||
'/subscription',
|
||||
SubscriptionRequestFactory::new()->invalid()->create()
|
||||
);
|
||||
|
||||
$this->assertErrors([
|
||||
'amount' => 'Interner Beitrag ist erforderlich.',
|
||||
|
|
|
@ -0,0 +1,42 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\RequestFactories;
|
||||
|
||||
use App\Fee;
|
||||
use Worksome\RequestFactories\RequestFactory;
|
||||
|
||||
class SubscriptionRequestFactory extends RequestFactory
|
||||
{
|
||||
public function definition(): array
|
||||
{
|
||||
return [
|
||||
'amount' => $this->faker->numberBetween(100, 2000),
|
||||
'fee_id' => Fee::factory()->create()->id,
|
||||
'name' => $this->faker->words(5, true),
|
||||
];
|
||||
}
|
||||
|
||||
public function amount(int $amount): self
|
||||
{
|
||||
return $this->state(['amount' => $amount]);
|
||||
}
|
||||
|
||||
public function fee(Fee $fee): self
|
||||
{
|
||||
return $this->state(['fee_id' => $fee->id]);
|
||||
}
|
||||
|
||||
public function name(string $name): self
|
||||
{
|
||||
return $this->state(['name' => $name]);
|
||||
}
|
||||
|
||||
public function invalid(): self
|
||||
{
|
||||
return $this->state([
|
||||
'amount' => '',
|
||||
'fee_id' => 9999,
|
||||
'name' => '',
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue