Add Pestphp
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
42ccd32740
commit
295d85f4f8
|
@ -10,7 +10,6 @@ parameters:
|
|||
|
||||
paths:
|
||||
- app
|
||||
- tests
|
||||
- database
|
||||
- packages/tex/src
|
||||
- packages/laravel-nami/src
|
||||
|
|
|
@ -5,20 +5,14 @@ namespace Tests\Feature\Invoice;
|
|||
use App\Invoice\Models\Invoice;
|
||||
use App\Invoice\Models\InvoicePosition;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InvoiceDestroyActionTest extends TestCase
|
||||
{
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
use DatabaseTransactions;
|
||||
it('testItDestroysInvoice', function () {
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$invoice = Invoice::factory()->has(InvoicePosition::factory()->withMember(), 'positions')->create();
|
||||
|
||||
public function testItDestroysInvoice(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$invoice = Invoice::factory()->has(InvoicePosition::factory()->withMember(), 'positions')->create();
|
||||
|
||||
$this->delete(route('invoice.destroy', ['invoice' => $invoice]))->assertOk();
|
||||
$this->assertDatabaseCount('invoices', 0);
|
||||
$this->assertDatabaseCount('invoice_positions', 0);
|
||||
}
|
||||
}
|
||||
$this->delete(route('invoice.destroy', ['invoice' => $invoice]))->assertOk();
|
||||
$this->assertDatabaseCount('invoices', 0);
|
||||
$this->assertDatabaseCount('invoice_positions', 0);
|
||||
});
|
||||
|
|
|
@ -9,96 +9,88 @@ use App\Invoice\Models\InvoicePosition;
|
|||
use App\Member\Member;
|
||||
use App\Payment\Subscription;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
use Tests\TestCase;
|
||||
|
||||
class InvoiceIndexActionTest extends TestCase
|
||||
{
|
||||
uses(DatabaseTransactions::class);
|
||||
|
||||
use DatabaseTransactions;
|
||||
it('testItDisplaysInvoices', function () {
|
||||
login()->loginNami()->withoutExceptionHandling();
|
||||
$subscription = Subscription::factory()->forFee()->name('Beitrag')->create();
|
||||
$member = Member::factory()->defaults()->create(['firstname' => 'Aaaa', 'lastname' => 'Aaab']);
|
||||
$invoice = Invoice::factory()
|
||||
->has(InvoicePosition::factory()->price(1100)->for($member)->state(['description' => 'lala']), 'positions')
|
||||
->has(InvoicePosition::factory()->price(2200)->withMember(), 'positions')
|
||||
->to(ReceiverRequestFactory::new()->name('Familie Blabla'))
|
||||
->sentAt(now()->subDay())
|
||||
->via(BillKind::POST)
|
||||
->status(InvoiceStatus::SENT)
|
||||
->create(['usage' => 'Usa', 'mail_email' => 'a@b.de']);
|
||||
|
||||
public function testItDisplaysInvoices(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
$subscription = Subscription::factory()->forFee()->name('Beitrag')->create();
|
||||
$member = Member::factory()->defaults()->create(['firstname' => 'Aaaa', 'lastname' => 'Aaab']);
|
||||
$invoice = Invoice::factory()
|
||||
->has(InvoicePosition::factory()->price(1100)->for($member)->state(['description' => 'lala']), 'positions')
|
||||
->has(InvoicePosition::factory()->price(2200)->withMember(), 'positions')
|
||||
->to(ReceiverRequestFactory::new()->name('Familie Blabla'))
|
||||
->sentAt(now()->subDay())
|
||||
->via(BillKind::POST)
|
||||
->status(InvoiceStatus::SENT)
|
||||
->create(['usage' => 'Usa', 'mail_email' => 'a@b.de']);
|
||||
test()->get(route('invoice.index'))
|
||||
->assertInertiaPath('data.data.0.to.name', 'Familie Blabla')
|
||||
->assertInertiaPath('data.data.0.id', $invoice->id)
|
||||
->assertInertiaPath('data.data.0.sum_human', '33,00 €')
|
||||
->assertInertiaPath('data.data.0.sent_at_human', now()->subDay()->format('d.m.Y'))
|
||||
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
|
||||
->assertInertiaPath('data.data.0.via', 'Post')
|
||||
->assertInertiaPath('data.data.0.mail_email', 'a@b.de')
|
||||
->assertInertiaPath('data.data.0.usage', 'Usa')
|
||||
->assertInertiaPath('data.data.0.greeting', $invoice->greeting)
|
||||
->assertInertiaPath('data.data.0.positions.0.price', 1100)
|
||||
->assertInertiaPath('data.data.0.positions.0.member_id', $member->id)
|
||||
->assertInertiaPath('data.data.0.positions.0.description', 'lala')
|
||||
->assertInertiaPath('data.data.0.positions.0.id', $invoice->positions->first()->id)
|
||||
->assertInertiaPath('data.data.0.links.pdf', route('invoice.pdf', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.rememberpdf', route('invoice.rememberpdf', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.update', route('invoice.update', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.destroy', route('invoice.destroy', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store'))
|
||||
->assertInertiaPath('data.meta.links.newInvoiceAttributes', route('invoice.new-invoice-attributes'))
|
||||
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
|
||||
->assertInertiaPath('data.meta.links.masspdf', route('invoice.masspdf'))
|
||||
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])
|
||||
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu'])
|
||||
->assertInertiaPath('data.meta.members.0', ['id' => $member->id, 'name' => 'Aaaa Aaab'])
|
||||
->assertInertiaPath('data.meta.subscriptions.0', ['name' => 'Beitrag', 'id' => $subscription->id])
|
||||
->assertInertiaPath('data.meta.filter.statuses', ['Neu', 'Rechnung gestellt'])
|
||||
->assertInertiaPath('data.meta.default', [
|
||||
'to' => [
|
||||
'name' => '',
|
||||
'address' => '',
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
],
|
||||
'positions' => [],
|
||||
'greeting' => '',
|
||||
'status' => InvoiceStatus::NEW->value,
|
||||
'via' => null,
|
||||
'usage' => '',
|
||||
'mail_email' => '',
|
||||
])
|
||||
->assertInertiaPath('data.meta.default_position', [
|
||||
'id' => null,
|
||||
'price' => 0,
|
||||
'description' => '',
|
||||
'member_id' => null,
|
||||
]);
|
||||
});
|
||||
|
||||
$this->get(route('invoice.index'))
|
||||
->assertInertiaPath('data.data.0.to.name', 'Familie Blabla')
|
||||
->assertInertiaPath('data.data.0.id', $invoice->id)
|
||||
->assertInertiaPath('data.data.0.sum_human', '33,00 €')
|
||||
->assertInertiaPath('data.data.0.sent_at_human', now()->subDay()->format('d.m.Y'))
|
||||
->assertInertiaPath('data.data.0.status', 'Rechnung gestellt')
|
||||
->assertInertiaPath('data.data.0.via', 'Post')
|
||||
->assertInertiaPath('data.data.0.mail_email', 'a@b.de')
|
||||
->assertInertiaPath('data.data.0.usage', 'Usa')
|
||||
->assertInertiaPath('data.data.0.greeting', $invoice->greeting)
|
||||
->assertInertiaPath('data.data.0.positions.0.price', 1100)
|
||||
->assertInertiaPath('data.data.0.positions.0.member_id', $member->id)
|
||||
->assertInertiaPath('data.data.0.positions.0.description', 'lala')
|
||||
->assertInertiaPath('data.data.0.positions.0.id', $invoice->positions->first()->id)
|
||||
->assertInertiaPath('data.data.0.links.pdf', route('invoice.pdf', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.rememberpdf', route('invoice.rememberpdf', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.update', route('invoice.update', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.data.0.links.destroy', route('invoice.destroy', ['invoice' => $invoice]))
|
||||
->assertInertiaPath('data.meta.links.mass-store', route('invoice.mass-store'))
|
||||
->assertInertiaPath('data.meta.links.newInvoiceAttributes', route('invoice.new-invoice-attributes'))
|
||||
->assertInertiaPath('data.meta.links.store', route('invoice.store'))
|
||||
->assertInertiaPath('data.meta.links.masspdf', route('invoice.masspdf'))
|
||||
->assertInertiaPath('data.meta.vias.0', ['id' => 'E-Mail', 'name' => 'E-Mail'])
|
||||
->assertInertiaPath('data.meta.statuses.0', ['id' => 'Neu', 'name' => 'Neu'])
|
||||
->assertInertiaPath('data.meta.members.0', ['id' => $member->id, 'name' => 'Aaaa Aaab'])
|
||||
->assertInertiaPath('data.meta.subscriptions.0', ['name' => 'Beitrag', 'id' => $subscription->id])
|
||||
->assertInertiaPath('data.meta.filter.statuses', ['Neu', 'Rechnung gestellt'])
|
||||
->assertInertiaPath('data.meta.default', [
|
||||
'to' => [
|
||||
'name' => '',
|
||||
'address' => '',
|
||||
'zip' => '',
|
||||
'location' => '',
|
||||
],
|
||||
'positions' => [],
|
||||
'greeting' => '',
|
||||
'status' => InvoiceStatus::NEW->value,
|
||||
'via' => null,
|
||||
'usage' => '',
|
||||
'mail_email' => '',
|
||||
])
|
||||
->assertInertiaPath('data.meta.default_position', [
|
||||
'id' => null,
|
||||
'price' => 0,
|
||||
'description' => '',
|
||||
'member_id' => null,
|
||||
]);
|
||||
}
|
||||
it('testValuesCanBeNull', function () {
|
||||
test()->login()->loginNami()->withoutExceptionHandling();
|
||||
Invoice::factory()->create();
|
||||
|
||||
public function testValuesCanBeNull(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Invoice::factory()->create();
|
||||
test()->get(route('invoice.index'))
|
||||
->assertInertiaPath('data.data.0.sent_at_human', '');
|
||||
});
|
||||
|
||||
$this->get(route('invoice.index'))
|
||||
->assertInertiaPath('data.data.0.sent_at_human', '');
|
||||
}
|
||||
it('testItFiltersForInvoiceStatus', function () {
|
||||
test()->login()->loginNami()->withoutExceptionHandling();
|
||||
Invoice::factory()->status(InvoiceStatus::NEW)->create();
|
||||
Invoice::factory()->status(InvoiceStatus::SENT)->count(2)->create();
|
||||
Invoice::factory()->status(InvoiceStatus::PAID)->count(3)->create();
|
||||
|
||||
public function testItFiltersForInvoiceStatus(): void
|
||||
{
|
||||
$this->login()->loginNami()->withoutExceptionHandling();
|
||||
Invoice::factory()->status(InvoiceStatus::NEW)->create();
|
||||
Invoice::factory()->status(InvoiceStatus::SENT)->count(2)->create();
|
||||
Invoice::factory()->status(InvoiceStatus::PAID)->count(3)->create();
|
||||
|
||||
$this->callFilter('invoice.index', [])->assertInertiaCount('data.data', 3);
|
||||
$this->callFilter('invoice.index', ['statuses' => []])->assertInertiaCount('data.data', 0);
|
||||
$this->callFilter('invoice.index', ['statuses' => ['Neu']])->assertInertiaCount('data.data', 1);
|
||||
$this->callFilter('invoice.index', ['statuses' => ['Neu', 'Rechnung beglichen']])->assertInertiaCount('data.data', 4);
|
||||
$this->callFilter('invoice.index', ['statuses' => ['Neu', 'Rechnung beglichen', 'Rechnung gestellt']])->assertInertiaCount('data.data', 6);
|
||||
}
|
||||
}
|
||||
test()->callFilter('invoice.index', [])->assertInertiaCount('data.data', 3);
|
||||
test()->callFilter('invoice.index', ['statuses' => []])->assertInertiaCount('data.data', 0);
|
||||
test()->callFilter('invoice.index', ['statuses' => ['Neu']])->assertInertiaCount('data.data', 1);
|
||||
test()->callFilter('invoice.index', ['statuses' => ['Neu', 'Rechnung beglichen']])->assertInertiaCount('data.data', 4);
|
||||
test()->callFilter('invoice.index', ['statuses' => ['Neu', 'Rechnung beglichen', 'Rechnung gestellt']])->assertInertiaCount('data.data', 6);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Test Case
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| The closure you provide to your test functions is always bound to a specific PHPUnit test
|
||||
| case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
||||
| need to change it using the "uses()" function to bind a different classes or traits.
|
||||
|
|
||||
*/
|
||||
|
||||
uses(
|
||||
Tests\TestCase::class,
|
||||
// Illuminate\Foundation\Testing\RefreshDatabase::class,
|
||||
)->in('Feature');
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Expectations
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| When you're writing tests, you often need to check that values meet certain conditions. The
|
||||
| "expect()" function gives you access to a set of "expectations" methods that you can use
|
||||
| to assert different things. Of course, you may extend the Expectation API at any time.
|
||||
|
|
||||
*/
|
||||
|
||||
// expect()->extend('toBeOne', function () {
|
||||
// return $this->toBe(1);
|
||||
// });
|
||||
|
||||
/*
|
||||
|--------------------------------------------------------------------------
|
||||
| Functions
|
||||
|--------------------------------------------------------------------------
|
||||
|
|
||||
| While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
||||
| project that you don't want to repeat in every file. Here you can also expose helpers as
|
||||
| global functions to help you to reduce the number of lines of code in your test files.
|
||||
|
|
||||
*/
|
|
@ -19,7 +19,7 @@ use Tests\Lib\TestsInertia;
|
|||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\TableDocument\TestsExcelDocuments;
|
||||
|
||||
abstract class TestCase extends BaseTestCase
|
||||
class TestCase extends BaseTestCase
|
||||
{
|
||||
use CreatesApplication;
|
||||
use TestsInertia;
|
||||
|
@ -28,7 +28,7 @@ abstract class TestCase extends BaseTestCase
|
|||
|
||||
protected User $me;
|
||||
|
||||
public function setUp(): void
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
Auth::fake();
|
||||
|
|
Loading…
Reference in New Issue