Fix tests
continuous-integration/drone/push Build is passing Details

This commit is contained in:
philipp lang 2024-09-21 18:56:53 +02:00
parent 295d85f4f8
commit 767df11e4f
6 changed files with 112 additions and 119 deletions

View File

@ -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 () => [

View File

@ -3,20 +3,19 @@
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;
public function testItDisplaysForms(): void
{
it('testItDisplaysForms', function () {
Carbon::setTestNow(Carbon::parse('2023-03-02'));
Storage::fake('temp');
$this->loginNami()->withoutExceptionHandling();
@ -46,10 +45,9 @@ class FormApiListActionTest extends FormTestCase
->assertJsonPath('meta.per_page', 15)
->assertJsonPath('meta.base_url', url(''))
->assertJsonPath('meta.total', 1);
}
});
public function testItDisplaysDefaultValueOfField(): void
{
it('testItDisplaysDefaultValueOfField', function () {
Storage::fake('temp');
$this->loginNami()->withoutExceptionHandling();
Form::factory()->withImage('headerImage', 'lala-2.jpg')
@ -58,10 +56,9 @@ class FormApiListActionTest extends FormTestCase
sleep(1);
$this->get('/api/form?perPage=15')->assertJsonPath('data.0.config.sections.0.fields.0.value', null);
}
});
public function testItDisplaysRemoteGroups(): void
{
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();
@ -71,10 +68,9 @@ class FormApiListActionTest extends FormTestCase
$this->get('/api/form?perPage=15')
->assertJsonPath('meta.agegroups.0', ['id' => 1, 'name' => 'Wölfling'])
->assertJsonCount(1, 'meta.agegroups');
}
});
public function testItDoesntDisplayInactiveForms(): void
{
it('testItDoesntDisplayInactiveForms', function () {
$this->loginNami()->withoutExceptionHandling();
Form::factory()->isActive(false)->withImage('headerImage', 'lala-2.jpg')->count(1)->create();
@ -86,10 +82,9 @@ class FormApiListActionTest extends FormTestCase
$this->get('/api/form?perPage=15&filter=' . $this->filterString([]))->assertJsonCount(2, 'data')
->assertJsonPath('data.0.is_active', true)
->assertJsonPath('data.0.is_private', false);
}
});
public function testItDisplaysDailyForms(): void
{
it('testItDisplaysDailyForms', function () {
Carbon::setTestNow(Carbon::parse('2023-03-02'));
$this->loginNami()->withoutExceptionHandling();
Form::factory()
@ -101,10 +96,9 @@ class FormApiListActionTest extends FormTestCase
sleep(1);
$this->get('/api/form')
->assertJsonPath('data.0.dates', '05.05.2023');
}
});
public function testItDisplaysPastEvents(): void
{
it('testItDisplaysPastEvents', function () {
Carbon::setTestNow(Carbon::parse('2023-05-10'));
$this->loginNami()->withoutExceptionHandling();
Form::factory()
@ -116,10 +110,9 @@ class FormApiListActionTest extends FormTestCase
sleep(1);
$this->get('/api/form?filter=' . $this->filterString(['past' => true]))
->assertJsonCount(1, 'data');
}
});
public function testItDisplaysAllForms(): void
{
it('testItDisplaysAllForms', function () {
Carbon::setTestNow(Carbon::parse('2023-03-02'));
Storage::fake('temp');
$this->loginNami()->withoutExceptionHandling();
@ -132,5 +125,4 @@ class FormApiListActionTest extends FormTestCase
sleep(1);
$this->get('/api/form')->assertJsonCount(20, 'data');
}
}
});

View File

@ -13,7 +13,7 @@ abstract class EndToEndTestCase extends TestCase
{
use DatabaseMigrations;
public function setUp(): void
protected function setUp(): void
{
parent::setUp();

View File

@ -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();

View File

@ -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()

View File

@ -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,