Lint
This commit is contained in:
parent
857051434e
commit
a0bcd99642
|
@ -79,7 +79,9 @@ abstract class Field extends Data
|
||||||
*/
|
*/
|
||||||
public function presentValue($value)
|
public function presentValue($value)
|
||||||
{
|
{
|
||||||
return [$this->key => $value];
|
return [
|
||||||
|
$this->key => $value,
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -4,15 +4,19 @@ namespace App\Form\Resources;
|
||||||
|
|
||||||
use App\Form\Fields\Field;
|
use App\Form\Fields\Field;
|
||||||
use App\Form\Models\Form;
|
use App\Form\Models\Form;
|
||||||
|
use App\Form\Models\Participant;
|
||||||
use Illuminate\Http\Resources\Json\JsonResource;
|
use Illuminate\Http\Resources\Json\JsonResource;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @mixin Participant
|
||||||
|
*/
|
||||||
class ParticipantResource extends JsonResource
|
class ParticipantResource extends JsonResource
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Transform the resource into an array.
|
* Transform the resource into an array.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param \Illuminate\Http\Request $request
|
||||||
* @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
|
* @return array<string, mixed>
|
||||||
*/
|
*/
|
||||||
public function toArray($request)
|
public function toArray($request)
|
||||||
{
|
{
|
||||||
|
@ -22,9 +26,12 @@ class ParticipantResource extends JsonResource
|
||||||
$attributes = $attributes->merge(Field::fromConfig($field)->presentValue($this->data[$field['key']]));
|
$attributes = $attributes->merge(Field::fromConfig($field)->presentValue($this->data[$field['key']]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return $attributes;
|
return $attributes->toArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
public static function meta(Form $form): array
|
public static function meta(Form $form): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Database\Factories\Form\Models;
|
namespace Database\Factories\Form\Models;
|
||||||
|
|
||||||
use App\Form\Models\Form;
|
|
||||||
use App\Form\Models\Participant;
|
use App\Form\Models\Participant;
|
||||||
use Illuminate\Database\Eloquent\Factories\Factory;
|
use Illuminate\Database\Eloquent\Factories\Factory;
|
||||||
use Tests\Feature\Form\FormtemplateSectionRequest;
|
use Tests\Feature\Form\FormtemplateSectionRequest;
|
||||||
|
@ -15,7 +14,7 @@ class ParticipantFactory extends Factory
|
||||||
/**
|
/**
|
||||||
* The name of the factory's corresponding model.
|
* The name of the factory's corresponding model.
|
||||||
*
|
*
|
||||||
* @var class-string<Form>
|
* @var class-string<Participant>
|
||||||
*/
|
*/
|
||||||
protected $model = Participant::class;
|
protected $model = Participant::class;
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ use Spatie\MediaLibrary\HasMedia;
|
||||||
trait FakesMedia
|
trait FakesMedia
|
||||||
{
|
{
|
||||||
|
|
||||||
public function withImage(string $collection, $filename): self
|
public function withImage(string $collection, string $filename): self
|
||||||
{
|
{
|
||||||
return $this->afterCreating(function (HasMedia $model) use ($filename, $collection) {
|
return $this->afterCreating(function (HasMedia $model) use ($filename, $collection) {
|
||||||
$pathinfo = pathinfo($filename);
|
$pathinfo = pathinfo($filename);
|
||||||
|
|
15
phpstan.neon
15
phpstan.neon
|
@ -532,3 +532,18 @@ parameters:
|
||||||
message: "#^Parameter \\#1 \\.\\.\\.\\$parts of method App\\\\Member\\\\FilterScope\\:\\:combinations\\(\\) expects array\\<int, int\\>, array\\<int, array\\<int, int\\>\\> given\\.$#"
|
message: "#^Parameter \\#1 \\.\\.\\.\\$parts of method App\\\\Member\\\\FilterScope\\:\\:combinations\\(\\) expects array\\<int, int\\>, array\\<int, array\\<int, int\\>\\> given\\.$#"
|
||||||
count: 1
|
count: 1
|
||||||
path: app/Member/FilterScope.php
|
path: app/Member/FilterScope.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Call to function is_null\\(\\) with array will always evaluate to false\\.$#"
|
||||||
|
count: 1
|
||||||
|
path: app/Form/Models/Form.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Unable to resolve the template type TKey in call to function collect$#"
|
||||||
|
count: 1
|
||||||
|
path: app/Form/Models/Form.php
|
||||||
|
|
||||||
|
-
|
||||||
|
message: "#^Unable to resolve the template type TValue in call to function collect$#"
|
||||||
|
count: 1
|
||||||
|
path: app/Form/Models/Form.php
|
||||||
|
|
|
@ -63,7 +63,7 @@ class FormIndexActionTest extends EndToEndTestCase
|
||||||
->assertInertiaPath('data.meta.section_default.name', '');
|
->assertInertiaPath('data.meta.section_default.name', '');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItHandlesFullTextSearch()
|
public function testItHandlesFullTextSearch(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
Form::factory()->to(now()->addYear())->name('ZEM 2024')->create();
|
||||||
|
@ -76,7 +76,7 @@ class FormIndexActionTest extends EndToEndTestCase
|
||||||
->assertInertiaCount('data.data', 2);
|
->assertInertiaCount('data.data', 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItOrdersByStartDateDesc()
|
public function testItOrdersByStartDateDesc(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
$form1 = Form::factory()->from(now()->addDays(4))->to(now()->addYear())->create();
|
||||||
|
@ -90,7 +90,7 @@ class FormIndexActionTest extends EndToEndTestCase
|
||||||
->assertInertiaPath('data.data.2.id', $form1->id);
|
->assertInertiaPath('data.data.2.id', $form1->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testItShowsPastEvents()
|
public function testItShowsPastEvents(): void
|
||||||
{
|
{
|
||||||
$this->withoutExceptionHandling()->login()->loginNami();
|
$this->withoutExceptionHandling()->login()->loginNami();
|
||||||
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
Form::factory()->count(5)->to(now()->subDays(2))->create();
|
||||||
|
|
|
@ -56,6 +56,8 @@ class FormRegisterActionTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider validationDataProvider
|
* @dataProvider validationDataProvider
|
||||||
|
* @param array<string, mixed> $payload
|
||||||
|
* @param ?array<string, mixed> $messages
|
||||||
*/
|
*/
|
||||||
public function testItValidatesInput(FormtemplateFieldRequest $fieldGenerator, array $payload, ?array $messages): void
|
public function testItValidatesInput(FormtemplateFieldRequest $fieldGenerator, array $payload, ?array $messages): void
|
||||||
{
|
{
|
||||||
|
@ -73,7 +75,7 @@ class FormRegisterActionTest extends TestCase
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function validationDataProvider(): Generator
|
public function validationDataProvider(): Generator
|
||||||
{
|
{
|
||||||
yield [
|
yield [
|
||||||
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(false)->key('birthday'),
|
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(false)->key('birthday'),
|
||||||
|
@ -89,7 +91,7 @@ class FormRegisterActionTest extends TestCase
|
||||||
|
|
||||||
yield [
|
yield [
|
||||||
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'),
|
FormtemplateFieldRequest::type(DateField::class)->name('Geburtsdatum')->maxToday(true)->key('birthday'),
|
||||||
['birthday' => now()->addDay(1)->format('Y-m-d')],
|
['birthday' => now()->addDay()->format('Y-m-d')],
|
||||||
['birthday' => 'Geburtsdatum muss ein Datum vor oder gleich dem ' . now()->format('d.m.Y') . ' sein.'],
|
['birthday' => 'Geburtsdatum muss ein Datum vor oder gleich dem ' . now()->format('d.m.Y') . ' sein.'],
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class FormStoreActionTest extends TestCase
|
||||||
$description = EditorRequestFactory::new()->text(10, 'Lorem');
|
$description = EditorRequestFactory::new()->text(10, 'Lorem');
|
||||||
FormRequest::new()
|
FormRequest::new()
|
||||||
->name('formname')
|
->name('formname')
|
||||||
->description($description->create())
|
->description($description)
|
||||||
->excerpt('avff')
|
->excerpt('avff')
|
||||||
->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->from('2023-07-07')->to('2023-07-08')
|
->registrationFrom('2023-05-04 01:00:00')->registrationUntil('2023-07-07 01:00:00')->from('2023-07-07')->to('2023-07-08')
|
||||||
->mailTop('Guten Tag')
|
->mailTop('Guten Tag')
|
||||||
|
|
|
@ -14,6 +14,8 @@ use Worksome\RequestFactories\RequestFactory;
|
||||||
* @method self default(mixed $default)
|
* @method self default(mixed $default)
|
||||||
* @method self options(array<int, string> $options)
|
* @method self options(array<int, string> $options)
|
||||||
* @method self maxToday(bool $maxToday)
|
* @method self maxToday(bool $maxToday)
|
||||||
|
* @method self parentGroup(int $groupId)
|
||||||
|
* @method self parentField(string $fieldKey)
|
||||||
*/
|
*/
|
||||||
class FormtemplateFieldRequest extends RequestFactory
|
class FormtemplateFieldRequest extends RequestFactory
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,8 +2,6 @@
|
||||||
|
|
||||||
namespace Tests\RequestFactories;
|
namespace Tests\RequestFactories;
|
||||||
|
|
||||||
use Illuminate\Http\UploadedFile;
|
|
||||||
use Illuminate\Support\Facades\Storage;
|
|
||||||
use Worksome\RequestFactories\RequestFactory;
|
use Worksome\RequestFactories\RequestFactory;
|
||||||
|
|
||||||
class EditorRequestFactory extends RequestFactory
|
class EditorRequestFactory extends RequestFactory
|
||||||
|
@ -27,6 +25,9 @@ class EditorRequestFactory extends RequestFactory
|
||||||
return $this->state($this->paragraphBlock($id, $text));
|
return $this->state($this->paragraphBlock($id, $text));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
public function paragraphBlock(int $id, string $text): array
|
public function paragraphBlock(int $id, string $text): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|
Loading…
Reference in New Issue