2022-11-18 15:55:44 +01:00
< ? php
namespace Tests\Feature\Member ;
2022-11-22 00:37:34 +01:00
use App\Course\Models\Course ;
use App\Course\Models\CourseMember ;
2022-11-19 00:09:53 +01:00
use App\Fee ;
use App\Gender ;
use App\Group ;
2022-11-22 00:37:34 +01:00
use App\Letter\BillKind ;
2022-11-18 15:55:44 +01:00
use App\Member\Member ;
use App\Member\Membership ;
2022-11-19 00:09:53 +01:00
use App\Nationality ;
2022-11-18 22:34:50 +01:00
use App\Payment\Payment ;
2022-11-19 00:09:53 +01:00
use App\Payment\Subscription ;
use App\Region ;
use Carbon\Carbon ;
2022-11-18 15:55:44 +01:00
use Illuminate\Foundation\Testing\DatabaseTransactions ;
use Tests\TestCase ;
class ShowTest extends TestCase
{
use DatabaseTransactions ;
2022-11-19 00:09:53 +01:00
public function setUp () : void
{
parent :: setUp ();
Carbon :: setTestNow ( Carbon :: parse ( '2006-01-01 15:00:00' ));
}
2022-11-18 15:55:44 +01:00
public function testItShowsSingleMember () : void
{
$this -> withoutExceptionHandling () -> login () -> loginNami ();
$member = Member :: factory ()
2022-11-19 00:09:53 +01:00
-> defaults ()
2022-11-18 15:55:44 +01:00
-> has ( Membership :: factory () -> in ( '€ LeiterIn' , 5 , 'Jungpfadfinder' , 88 ) -> state ([ 'created_at' => '2022-11-19 05:00:00' ]))
2022-11-18 22:34:50 +01:00
-> has ( Payment :: factory () -> notPaid () -> nr ( '2019' ) -> subscription ( 'Free' , 1050 ))
2022-11-19 00:21:58 +01:00
-> for ( Gender :: factory () -> name ( 'Männlich' ))
2022-11-19 00:09:53 +01:00
-> for ( Region :: factory () -> name ( 'NRW' ))
2022-11-22 00:37:34 +01:00
-> for ( BillKind :: factory () -> name ( 'Post' ))
-> inNami ( 123 )
-> for ( Subscription :: factory () -> name ( 'Sub' ) -> for ( Fee :: factory ()))
-> has ( CourseMember :: factory () -> for ( Course :: factory () -> name ( ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ' )) -> state ([ 'organizer' => 'DPSG' , 'event_name' => 'Wochenende' , 'completed_at' => '2022-03-03' ]), 'courses' )
2022-11-19 00:09:53 +01:00
-> create ([
'birthday' => '1991-04-20' ,
'address' => 'Itterstr 3' ,
'zip' => '42719' ,
'location' => 'Solingen' ,
'firstname' => 'Max' ,
2022-11-19 00:21:58 +01:00
'lastname' => 'Muster' ,
2022-11-19 00:09:53 +01:00
'other_country' => 'other' ,
'main_phone' => '+49 212 1266775' ,
'mobile_phone' => '+49 212 1266776' ,
'work_phone' => '+49 212 1266777' ,
'children_phone' => '+49 212 1266778' ,
'email' => 'a@b.de' ,
'email_parents' => 'b@c.de' ,
'fax' => '+49 212 1255674' ,
2022-11-22 00:37:34 +01:00
'efz' => '2022-09-20' ,
'ps_at' => '2022-04-20' ,
'more_ps_at' => '2022-06-02' ,
'without_education_at' => '2022-06-03' ,
'without_efz_at' => '2022-06-04' ,
'has_vk' => true ,
'has_svk' => true ,
'multiply_pv' => true ,
'multiply_more_pv' => true ,
'send_newspaper' => true ,
'joined_at' => '2022-06-11' ,
2022-11-19 00:09:53 +01:00
]);
2022-11-18 15:55:44 +01:00
$response = $this -> get ( " /member/ { $member -> id } " );
2022-11-19 00:09:53 +01:00
$this -> assertInertiaHas ([
'birthday_human' => '20.04.1991' ,
'age' => 14 ,
'full_address' => 'Itterstr 3, 42719 Solingen' ,
'region' => [ 'name' => 'NRW' ],
'other_country' => 'other' ,
'main_phone' => '+49 212 1266775' ,
'mobile_phone' => '+49 212 1266776' ,
'work_phone' => '+49 212 1266777' ,
'children_phone' => '+49 212 1266778' ,
'email' => 'a@b.de' ,
'email_parents' => 'b@c.de' ,
'fax' => '+49 212 1255674' ,
2022-11-19 00:21:58 +01:00
'fullname' => 'Herr Max Muster' ,
2022-11-22 00:37:34 +01:00
'efz_human' => '20.09.2022' ,
'ps_at_human' => '20.04.2022' ,
'more_ps_at_human' => '02.06.2022' ,
'without_education_at_human' => '03.06.2022' ,
'without_efz_at_human' => '04.06.2022' ,
'has_vk' => true ,
'has_svk' => true ,
'multiply_pv' => true ,
'multiply_more_pv' => true ,
'has_nami' => true ,
'nami_id' => 123 ,
'send_newspaper' => true ,
'joined_at_human' => '11.06.2022' ,
'bill_kind_name' => 'Post' ,
'subscription' => [
'name' => 'Sub' ,
],
2022-11-19 00:09:53 +01:00
], $response , 'data' );
2022-11-18 15:55:44 +01:00
$this -> assertInertiaHas ([
'activity_name' => '€ LeiterIn' ,
2022-11-22 00:37:34 +01:00
'subactivity_name' => 'Jungpfadfinder' ,
2022-11-18 15:55:44 +01:00
'id' => $member -> memberships -> first () -> id ,
'human_date' => '19.11.2022' ,
], $response , 'data.memberships.0' );
2022-11-22 00:37:34 +01:00
$this -> assertInertiaHas ([
'organizer' => 'DPSG' ,
'event_name' => 'Wochenende' ,
'completed_at_human' => '03.03.2022' ,
'course' => [
'name' => ' Baustein 2e - Gewalt gegen Kinder und Jugendliche: Vertiefung, Prävention ' ,
'short_name' => '2e' ,
],
], $response , 'data.courses.0' );
2022-11-18 22:34:50 +01:00
$this -> assertInertiaHas ([
'subscription' => [
'name' => 'Free' ,
'id' => $member -> payments -> first () -> subscription -> id ,
'amount' => 1050 ,
2022-11-22 00:37:34 +01:00
'amount_human' => '10,50 €' ,
2022-11-18 22:34:50 +01:00
],
'status_name' => 'Nicht bezahlt' ,
'nr' => '2019' ,
], $response , 'data.payments.0' );
2022-11-18 15:55:44 +01:00
}
2022-11-19 00:09:53 +01:00
public function testItShowsMinimalSingleMember () : void
{
$this -> withoutExceptionHandling () -> login () -> loginNami ();
$member = Member :: factory ()
-> for ( Group :: factory ())
-> for ( Nationality :: factory () -> name ( 'deutsch' ))
-> for ( Subscription :: factory () -> for ( Fee :: factory ()))
2022-11-19 00:21:58 +01:00
-> create ([ 'firstname' => 'Max' , 'lastname' => 'Muster' ]);
2022-11-19 00:09:53 +01:00
$response = $this -> get ( " /member/ { $member -> id } " );
$this -> assertInertiaHas ([
'region' => [ 'name' => '-- kein --' ],
2022-11-19 00:21:58 +01:00
'fullname' => 'Max Muster' ,
2022-11-19 00:09:53 +01:00
'nationality' => [
'name' => 'deutsch' ,
],
2022-11-22 00:37:34 +01:00
'efz_human' => null ,
'ps_at_human' => null ,
'more_ps_at_human' => null ,
'without_education_at_human' => null ,
'without_efz_at_human' => null ,
'has_vk' => false ,
'has_svk' => false ,
'multiply_pv' => false ,
'multiply_more_pv' => false ,
2022-11-19 00:09:53 +01:00
], $response , 'data' );
}
2022-11-18 15:55:44 +01:00
}