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 App\Fee;
|
||||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||||
|
use Tests\RequestFactories\SubscriptionRequestFactory;
|
||||||
use Tests\TestCase;
|
use Tests\TestCase;
|
||||||
|
|
||||||
class StoreTest extends TestCase
|
class StoreTest extends TestCase
|
||||||
|
@ -15,11 +16,10 @@ class StoreTest extends TestCase
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$fee = Fee::factory()->create();
|
$fee = Fee::factory()->create();
|
||||||
|
|
||||||
$response = $this->from('/subscription')->post('/subscription', [
|
$response = $this->from('/subscription')->post(
|
||||||
'amount' => 2500,
|
'/subscription',
|
||||||
'fee_id' => $fee->id,
|
SubscriptionRequestFactory::new()->amount(2500)->fee($fee)->name('lorem')->create()
|
||||||
'name' => 'Lorem',
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
$response->assertRedirect('/subscription');
|
$response->assertRedirect('/subscription');
|
||||||
$this->assertDatabaseHas('subscriptions', [
|
$this->assertDatabaseHas('subscriptions', [
|
||||||
|
@ -34,11 +34,10 @@ class StoreTest extends TestCase
|
||||||
$this->login()->loginNami();
|
$this->login()->loginNami();
|
||||||
$fee = Fee::factory()->create();
|
$fee = Fee::factory()->create();
|
||||||
|
|
||||||
$response = $this->post('/subscription', [
|
$response = $this->post(
|
||||||
'amount' => '',
|
'/subscription',
|
||||||
'fee_id' => 99,
|
SubscriptionRequestFactory::new()->invalid()->create()
|
||||||
'name' => '',
|
);
|
||||||
]);
|
|
||||||
|
|
||||||
$this->assertErrors([
|
$this->assertErrors([
|
||||||
'amount' => 'Interner Beitrag ist erforderlich.',
|
'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