diff --git a/app/Form/Models/Form.php b/app/Form/Models/Form.php index d4552aae..52abfa64 100644 --- a/app/Form/Models/Form.php +++ b/app/Form/Models/Form.php @@ -12,6 +12,7 @@ use Illuminate\Database\Eloquent\Factories\HasFactory; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\HasMany; use Laravel\Scout\Searchable; +use Spatie\Image\Enums\Fit; use Spatie\Image\Manipulations; use Spatie\MediaLibrary\HasMedia; use Spatie\MediaLibrary\InteractsWithMedia; @@ -74,7 +75,7 @@ class Form extends Model implements HasMedia ->forceFileName(fn (Form $model, string $name) => $model->slug) ->convert(fn () => 'jpg') ->registerMediaConversions(function (Media $media) { - $this->addMediaConversion('square')->fit(Manipulations::FIT_CROP, 400, 400); + $this->addMediaConversion('square')->fit(Fit::Crop, 400, 400); }); $this->addMediaCollection('mailattachments') ->withDefaultProperties(fn () => [ diff --git a/tests/EndToEnd/Form/FormApiListActionTest.php b/tests/EndToEnd/Form/FormApiListActionTest.php index c00c4d5b..96b6a57f 100644 --- a/tests/EndToEnd/Form/FormApiListActionTest.php +++ b/tests/EndToEnd/Form/FormApiListActionTest.php @@ -3,134 +3,126 @@ namespace Tests\EndToEnd\Form; use App\Form\Models\Form; +use App\Membership\TestersBlock; use App\Subactivity; use Carbon\Carbon; use Illuminate\Foundation\Testing\DatabaseTransactions; use Illuminate\Support\Facades\Storage; use Tests\Feature\Form\FormtemplateSectionRequest; use Tests\RequestFactories\EditorRequestFactory; +use Tests\TestCase; -class FormApiListActionTest extends FormTestCase -{ +uses(FormTestCase::class); +uses(DatabaseTransactions::class); - use DatabaseTransactions; +it('testItDisplaysForms', function () { + Carbon::setTestNow(Carbon::parse('2023-03-02')); + Storage::fake('temp'); + $this->loginNami()->withoutExceptionHandling(); + $form = Form::factory() + ->name('lala 2') + ->excerpt('fff') + ->withImage('headerImage', 'lala-2.jpg') + ->description(EditorRequestFactory::new()->text(10, 'desc')) + ->from('2023-05-05') + ->to('2023-06-07') + ->sections([FormtemplateSectionRequest::new()->name('sname')]) + ->create(); - public function testItDisplaysForms(): void - { - Carbon::setTestNow(Carbon::parse('2023-03-02')); - Storage::fake('temp'); - $this->loginNami()->withoutExceptionHandling(); - $form = Form::factory() - ->name('lala 2') - ->excerpt('fff') - ->withImage('headerImage', 'lala-2.jpg') - ->description(EditorRequestFactory::new()->text(10, 'desc')) - ->from('2023-05-05') - ->to('2023-06-07') - ->sections([FormtemplateSectionRequest::new()->name('sname')]) - ->create(); + sleep(1); + $this->get('/api/form?perPage=15') + ->assertOk() + ->assertJsonPath('data.0.name', 'lala 2') + ->assertJsonPath('data.0.config.sections.0.name', 'sname') + ->assertJsonPath('data.0.id', $form->id) + ->assertJsonPath('data.0.excerpt', 'fff') + ->assertJsonPath('data.0.description.blocks.0.data.text', 'desc') + ->assertJsonPath('data.0.slug', 'lala-2') + ->assertJsonPath('data.0.image', $form->getMedia('headerImage')->first()->getFullUrl('square')) + ->assertJsonPath('data.0.dates', '05.05.2023 - 07.06.2023') + ->assertJsonPath('data.0.from_human', '05.05.2023') + ->assertJsonPath('data.0.to_human', '07.06.2023') + ->assertJsonPath('meta.per_page', 15) + ->assertJsonPath('meta.base_url', url('')) + ->assertJsonPath('meta.total', 1); +}); - sleep(1); - $this->get('/api/form?perPage=15') - ->assertOk() - ->assertJsonPath('data.0.name', 'lala 2') - ->assertJsonPath('data.0.config.sections.0.name', 'sname') - ->assertJsonPath('data.0.id', $form->id) - ->assertJsonPath('data.0.excerpt', 'fff') - ->assertJsonPath('data.0.description.blocks.0.data.text', 'desc') - ->assertJsonPath('data.0.slug', 'lala-2') - ->assertJsonPath('data.0.image', $form->getMedia('headerImage')->first()->getFullUrl('square')) - ->assertJsonPath('data.0.dates', '05.05.2023 - 07.06.2023') - ->assertJsonPath('data.0.from_human', '05.05.2023') - ->assertJsonPath('data.0.to_human', '07.06.2023') - ->assertJsonPath('meta.per_page', 15) - ->assertJsonPath('meta.base_url', url('')) - ->assertJsonPath('meta.total', 1); - } +it('testItDisplaysDefaultValueOfField', function () { + Storage::fake('temp'); + $this->loginNami()->withoutExceptionHandling(); + Form::factory()->withImage('headerImage', 'lala-2.jpg') + ->sections([FormtemplateSectionRequest::new()->fields([$this->textField()])]) + ->create(); - public function testItDisplaysDefaultValueOfField(): void - { - Storage::fake('temp'); - $this->loginNami()->withoutExceptionHandling(); - Form::factory()->withImage('headerImage', 'lala-2.jpg') - ->sections([FormtemplateSectionRequest::new()->fields([$this->textField()])]) - ->create(); + sleep(1); + $this->get('/api/form?perPage=15')->assertJsonPath('data.0.config.sections.0.fields.0.value', null); +}); - sleep(1); - $this->get('/api/form?perPage=15')->assertJsonPath('data.0.config.sections.0.fields.0.value', null); - } +it('testItDisplaysRemoteGroups', function () { + $this->loginNami()->withoutExceptionHandling(); + Subactivity::factory()->inNami(1)->name('Wölfling')->ageGroup(true)->create(); + Subactivity::factory()->inNami(50)->name('Biber')->ageGroup(false)->create(); + Subactivity::factory()->name('Lager')->ageGroup(true)->create(); - public function testItDisplaysRemoteGroups(): void - { - $this->loginNami()->withoutExceptionHandling(); - Subactivity::factory()->inNami(1)->name('Wölfling')->ageGroup(true)->create(); - Subactivity::factory()->inNami(50)->name('Biber')->ageGroup(false)->create(); - Subactivity::factory()->name('Lager')->ageGroup(true)->create(); + sleep(1); + $this->get('/api/form?perPage=15') + ->assertJsonPath('meta.agegroups.0', ['id' => 1, 'name' => 'Wölfling']) + ->assertJsonCount(1, 'meta.agegroups'); +}); - sleep(1); - $this->get('/api/form?perPage=15') - ->assertJsonPath('meta.agegroups.0', ['id' => 1, 'name' => 'Wölfling']) - ->assertJsonCount(1, 'meta.agegroups'); - } +it('testItDoesntDisplayInactiveForms', function () { + $this->loginNami()->withoutExceptionHandling(); - public function testItDoesntDisplayInactiveForms(): void - { - $this->loginNami()->withoutExceptionHandling(); + Form::factory()->isActive(false)->withImage('headerImage', 'lala-2.jpg')->count(1)->create(); + Form::factory()->isActive(true)->withImage('headerImage', 'lala-2.jpg')->count(2)->create(); - Form::factory()->isActive(false)->withImage('headerImage', 'lala-2.jpg')->count(1)->create(); - Form::factory()->isActive(true)->withImage('headerImage', 'lala-2.jpg')->count(2)->create(); + sleep(1); + $this->get('/api/form?perPage=15&filter=' . $this->filterString(['inactive' => true]))->assertJsonCount(3, 'data'); + $this->get('/api/form?perPage=15&filter=' . $this->filterString(['inactive' => false]))->assertJsonCount(2, 'data'); + $this->get('/api/form?perPage=15&filter=' . $this->filterString([]))->assertJsonCount(2, 'data') + ->assertJsonPath('data.0.is_active', true) + ->assertJsonPath('data.0.is_private', false); +}); - sleep(1); - $this->get('/api/form?perPage=15&filter=' . $this->filterString(['inactive' => true]))->assertJsonCount(3, 'data'); - $this->get('/api/form?perPage=15&filter=' . $this->filterString(['inactive' => false]))->assertJsonCount(2, 'data'); - $this->get('/api/form?perPage=15&filter=' . $this->filterString([]))->assertJsonCount(2, 'data') - ->assertJsonPath('data.0.is_active', true) - ->assertJsonPath('data.0.is_private', false); - } +it('testItDisplaysDailyForms', function () { + Carbon::setTestNow(Carbon::parse('2023-03-02')); + $this->loginNami()->withoutExceptionHandling(); + Form::factory() + ->withImage('headerImage', 'lala-2.jpg') + ->from('2023-05-05') + ->to('2023-05-05') + ->create(); - public function testItDisplaysDailyForms(): void - { - Carbon::setTestNow(Carbon::parse('2023-03-02')); - $this->loginNami()->withoutExceptionHandling(); - Form::factory() - ->withImage('headerImage', 'lala-2.jpg') - ->from('2023-05-05') - ->to('2023-05-05') - ->create(); + sleep(1); + $this->get('/api/form') + ->assertJsonPath('data.0.dates', '05.05.2023'); +}); - sleep(1); - $this->get('/api/form') - ->assertJsonPath('data.0.dates', '05.05.2023'); - } +it('testItDisplaysPastEvents', function () { + Carbon::setTestNow(Carbon::parse('2023-05-10')); + $this->loginNami()->withoutExceptionHandling(); + Form::factory() + ->withImage('headerImage', 'lala-2.jpg') + ->from('2023-05-05') + ->to('2023-05-05') + ->create(); - public function testItDisplaysPastEvents(): void - { - Carbon::setTestNow(Carbon::parse('2023-05-10')); - $this->loginNami()->withoutExceptionHandling(); - Form::factory() - ->withImage('headerImage', 'lala-2.jpg') - ->from('2023-05-05') - ->to('2023-05-05') - ->create(); + sleep(1); + $this->get('/api/form?filter=' . $this->filterString(['past' => true])) + ->assertJsonCount(1, 'data'); +}); - sleep(1); - $this->get('/api/form?filter=' . $this->filterString(['past' => true])) - ->assertJsonCount(1, 'data'); - } +it('testItDisplaysAllForms', function () { + Carbon::setTestNow(Carbon::parse('2023-03-02')); + Storage::fake('temp'); + $this->loginNami()->withoutExceptionHandling(); + Form::factory() + ->withImage('headerImage', 'lala-2.jpg') + ->from('2023-05-05') + ->to('2023-06-07') + ->count(20) + ->create(); - public function testItDisplaysAllForms(): void - { - Carbon::setTestNow(Carbon::parse('2023-03-02')); - Storage::fake('temp'); - $this->loginNami()->withoutExceptionHandling(); - Form::factory() - ->withImage('headerImage', 'lala-2.jpg') - ->from('2023-05-05') - ->to('2023-06-07') - ->count(20) - ->create(); - - sleep(1); - $this->get('/api/form')->assertJsonCount(20, 'data'); - } -} + sleep(1); + $this->get('/api/form')->assertJsonCount(20, 'data'); +}); diff --git a/tests/EndToEndTestCase.php b/tests/EndToEndTestCase.php index cba5c944..09c5855e 100644 --- a/tests/EndToEndTestCase.php +++ b/tests/EndToEndTestCase.php @@ -13,7 +13,7 @@ abstract class EndToEndTestCase extends TestCase { use DatabaseMigrations; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Form/FormTestCase.php b/tests/Feature/Form/FormTestCase.php index 43875b9f..4b1f1a39 100644 --- a/tests/Feature/Form/FormTestCase.php +++ b/tests/Feature/Form/FormTestCase.php @@ -14,7 +14,7 @@ class FormTestCase extends TestCase private string $clearCacheUrl = 'http://event.com/clear-cache'; - public function setUp(): void + protected function setUp(): void { parent::setUp(); diff --git a/tests/Feature/Invoice/InvoiceIndexActionTest.php b/tests/Feature/Invoice/InvoiceIndexActionTest.php index a8e64244..46ab2bef 100644 --- a/tests/Feature/Invoice/InvoiceIndexActionTest.php +++ b/tests/Feature/Invoice/InvoiceIndexActionTest.php @@ -13,7 +13,7 @@ use Illuminate\Foundation\Testing\DatabaseTransactions; uses(DatabaseTransactions::class); it('testItDisplaysInvoices', function () { - login()->loginNami()->withoutExceptionHandling(); + $this->login()->loginNami()->withoutExceptionHandling(); $subscription = Subscription::factory()->forFee()->name('Beitrag')->create(); $member = Member::factory()->defaults()->create(['firstname' => 'Aaaa', 'lastname' => 'Aaab']); $invoice = Invoice::factory() diff --git a/tests/Feature/Member/StoreTest.php b/tests/Feature/Member/StoreTest.php index ec9dbf32..174a2717 100644 --- a/tests/Feature/Member/StoreTest.php +++ b/tests/Feature/Member/StoreTest.php @@ -62,7 +62,7 @@ class StoreTest extends TestCase 'address' => 'Bavert 50', 'bill_kind' => 'Post', 'birthday' => '2013-02-19', - 'children_phone' => '+49 176 8574112', + 'children_phone' => '+49 176 70512778', 'country_id' => $country->id, 'email_parents' => 'osloot@aol.com', 'firstname' => 'Joe', @@ -71,8 +71,8 @@ class StoreTest extends TestCase 'lastname' => 'Muster', 'letter_address' => null, 'location' => 'Solingen', - 'main_phone' => '+49 212 2334322', - 'mobile_phone' => '+49 176 3033053', + 'main_phone' => '+49 212 337056', + 'mobile_phone' => '+49 176 70512774', 'nationality_id' => $nationality->id, 'region_id' => $region->id, 'send_newspaper' => '1', @@ -230,7 +230,7 @@ class StoreTest extends TestCase return [ 'address' => 'Bavert 50', 'birthday' => '2013-02-19', - 'children_phone' => '+49 176 8574112', + 'children_phone' => '+49 176 70512778', 'efz' => '', 'email' => '', 'email_parents' => 'osloot@aol.com', @@ -244,8 +244,8 @@ class StoreTest extends TestCase 'lastname' => 'Muster', 'letter_address' => '', 'location' => 'Solingen', - 'main_phone' => '+49 212 2334322', - 'mobile_phone' => '+49 176 3033053', + 'main_phone' => '+49 212 337056', + 'mobile_phone' => '+49 176 70512774', 'more_ps_at' => '', 'multiply_more_pv' => false, 'multiply_pv' => false,