Mod member test
This commit is contained in:
parent
7b5fc2efcc
commit
f37c003ffc
|
@ -4,10 +4,10 @@ namespace Zoomyboy\LaravelNami\Tests;
|
||||||
|
|
||||||
use Illuminate\Support\Facades\Config;
|
use Illuminate\Support\Facades\Config;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Zoomyboy\LaravelNami\Tests\Stub\Member;
|
|
||||||
use Zoomyboy\LaravelNami\Providers\NamiServiceProvider;
|
|
||||||
use Zoomyboy\LaravelNami\Cookies\Cookie;
|
use Zoomyboy\LaravelNami\Cookies\Cookie;
|
||||||
use Zoomyboy\LaravelNami\Cookies\FakeCookie;
|
use Zoomyboy\LaravelNami\Cookies\FakeCookie;
|
||||||
|
use Zoomyboy\LaravelNami\Providers\NamiServiceProvider;
|
||||||
|
use Zoomyboy\LaravelNami\Tests\Stub\Member;
|
||||||
|
|
||||||
class TestCase extends \Orchestra\Testbench\TestCase
|
class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
{
|
{
|
||||||
|
@ -43,8 +43,10 @@ class TestCase extends \Orchestra\Testbench\TestCase
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fakeJson($file) {
|
public function fakeJson(string $file, array $data = []): string {
|
||||||
return file_get_contents(__DIR__.'/json/'.$file);
|
ob_start();
|
||||||
|
include(__DIR__.'/json/'.$file);
|
||||||
|
return ob_get_clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function fakeGenders() {
|
public function fakeGenders() {
|
||||||
|
|
|
@ -17,32 +17,40 @@ class PullMemberTest extends TestCase
|
||||||
|
|
||||||
public function dataProvider(): array {
|
public function dataProvider(): array {
|
||||||
return [
|
return [
|
||||||
'firstname' => ['firstname', ['Max', 'Jane']],
|
'firstname' => [ ['vorname' => 'Max'], ['firstname' => 'Max' ] ],
|
||||||
'lastname' => ['lastname', ['Nach1', 'Nach2']],
|
'lastname' => [ ['nachname' => 'Nach'], ['lastname' => 'Nach' ] ],
|
||||||
'nickname' => ['nickname', ['spitz1', null]],
|
'nickname' => [ ['spitzname' => 'spitz1'], ['nickname' => 'spitz1'] ],
|
||||||
'other_country' => ['other_country', ['deutsch', null]],
|
'nicknameEmpty' => [ ['spitzname' => null], ['nickname' => null] ],
|
||||||
'address' => ['address', ['straße 1', 'straße 2']],
|
'other_country' => [ ['staatsangehoerigkeitText' => 'deutsch'], ['other_country' => 'deutsch'] ],
|
||||||
'further_address' => ['further_address', ['addrz', null]],
|
'other_countryEmpty' => [ ['staatsangehoerigkeitText' => ''], ['other_country' => null] ],
|
||||||
'zip' => ['zip', ['12345', '5555']],
|
'address' => [ ['strasse' => 'Straße 1'], ['address' => 'Straße 1'] ],
|
||||||
'location' => ['location', ['SG', 'Köln']],
|
'further_address' => [ ['nameZusatz' => 'addrz'], ['further_address' => 'addrz'] ],
|
||||||
'main_phone' => ['main_phone', ['+49888', '+49668']],
|
'further_addressEmpty' => [ ['nameZusatz' => ''], ['further_address' => null] ],
|
||||||
'mobile_phone' => ['mobile_phone', ['+49176', '+49172']],
|
'zip' => [ ['plz' => '12345'], ['zip' => '12345'] ],
|
||||||
'work_phone' => ['work_phone', ['+11111', '+22222']],
|
'location' => [ ['ort' => 'Köln'], ['location' => 'Köln'] ],
|
||||||
'fax' => ['fax', ['+55111', '+55222']],
|
'main_phone' => [ ['telefon1' => '+49888'], ['main_phone' => '+49888'] ],
|
||||||
'email' => ['email', ['test@example.com', 'test2@example.com']],
|
'mobile_phone' => [ ['telefon2' => '+49176'], ['mobile_phone' => '+49176'] ],
|
||||||
'email_parents' => ['email_parents', ['testp@example.com', 'test2p@example.com']],
|
'work_phone' => [ ['telefon3' => '+49177'], ['work_phone' => '+49177'] ],
|
||||||
'gender_id' => ['gender_id', [19, null]],
|
'fax' => [ ['telefax' => '+55111'], ['fax' => '+55111'] ],
|
||||||
'nationality_id' => ['nationality_id', [1054, null]],
|
'email' => [ ['email' => 'a@b.de'], ['email' => 'a@b.de'] ],
|
||||||
'confession_id' => ['confession_id', [1, null]],
|
'email_parents' => [ ['emailVertretungsberechtigter' => 'v@b.de'], ['email_parents' => 'v@b.de'] ],
|
||||||
'birthday' => ['birthday', ['1991-06-20', '1984-01-17']],
|
'gender_id' => [ ['geschlechtId' => 19], ['gender_id' => 19] ],
|
||||||
'joined_at' => ['joined_at', ['2005-05-01', null]],
|
'gender_idEmpty' => [ ['geschlechtId' => 23], ['gender_id' => null] ],
|
||||||
'group_id' => ['group_id', [103, 103]],
|
'nationality_id' => [ ['staatsangehoerigkeitId' => 1054], ['nationality_id' => 1054] ],
|
||||||
'mitgliedsnr' => ['mitgliedsnr', [12345, null]],
|
'nationality_idEmpty' => [ ['staatsangehoerigkeitId' => null], ['nationality_id' => null] ],
|
||||||
'updated_at' => ['updated_at', ['2020-06-28 02:15:24', '2015-02-03 15:20:07']],
|
'confession_id' => [ ['konfessionId' => 1], ['confession_id' => 1] ],
|
||||||
'send_newspaper' => ['send_newspaper', [true, false]],
|
'confession_idEmpty' => [ ['konfessionId' => null], ['confession_id' => null] ],
|
||||||
'region_id' => ['region_id', [10, null]],
|
'birthday' => [ ['geburtsDatum' => "1991-06-20 00:00:00"], ['birthday' => "1991-06-20"] ],
|
||||||
'country_id' => ['country_id', [100, 101]],
|
'joined_at' => [ ['eintrittsdatum' => "2005-05-01 00:00:00"], ['joined_at' => "2005-05-01"] ],
|
||||||
'fee_id' => ['fee_id', [1, 15]],
|
'group_id' => [ ['gruppierungId' => 103], ['group_id' => 103] ],
|
||||||
|
'mitgliedsnr' => [ ['mitgliedsNummer' => 12345], ['mitgliedsnr' => 12345] ],
|
||||||
|
'mitgliedsnrEmpty' => [ ['mitgliedsNummer' => null], ['mitgliedsnr' => null] ],
|
||||||
|
'updated_at' => [ ['lastUpdated' => "2020-06-28 02:15:24"], ['updated_at' => '2020-06-28 02:15:24'] ],
|
||||||
|
'send_newspaper' => [ ['zeitschriftenversand' => true], ['send_newspaper' => true] ],
|
||||||
|
'region_id' => [ ['regionId' => 10], ['region_id' => 10] ],
|
||||||
|
'region_idEmpty' => [ ['regionId' => null], ['region_id' => null] ],
|
||||||
|
'country_id' => [ ['landId' => 100], ['country_id' => 100] ],
|
||||||
|
'fee_id' => [ ['beitragsartId' => 1], ['fee_id' => 1] ],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,48 +84,43 @@ class PullMemberTest extends TestCase
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProvider
|
* @dataProvider dataProvider
|
||||||
*/
|
*/
|
||||||
public function test_get_a_single_member(string $key, array $values): void
|
public function test_get_a_single_member(array $input, array $check): void
|
||||||
{
|
{
|
||||||
Http::fake(array_merge($this->login(), [
|
Http::fake(array_merge($this->login(), [
|
||||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json'), 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json', ['data' => $input]), 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response($this->fakeJson('member-17.json'), 200)
|
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$this->setCredentials();
|
$this->setCredentials();
|
||||||
|
|
||||||
Nami::login();
|
Nami::login();
|
||||||
|
|
||||||
$group = Nami::group(103);
|
$group = Nami::group(103);
|
||||||
|
|
||||||
$this->assertSame($values[0], $group->member(16)->toArray()[$key]);
|
foreach ($check as $key => $value) {
|
||||||
$this->assertSame($values[1], $group->member(17)->toArray()[$key]);
|
$this->assertSame($value, $group->member(16)->toArray()[$key]);
|
||||||
|
}
|
||||||
|
|
||||||
Http::assertSentCount(5);
|
Http::assertSentCount(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dataProvider dataProvider
|
* @dataProvider dataProvider
|
||||||
*/
|
*/
|
||||||
public function test_get_attribute_of_member_collection(string $key, array $values): void
|
public function test_get_attribute_of_member_collection(array $input, array $check): void
|
||||||
{
|
{
|
||||||
Http::fake(array_merge($this->login(), [
|
Http::fake(array_merge($this->login(), [
|
||||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/flist' => Http::response($this->fakeJson('member_overview.json'), 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/flist' => Http::response($this->fakeJson('member_overview.json'), 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json'), 200),
|
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response($this->fakeJson('member-16.json', ['data' => $input]), 200),
|
||||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response($this->fakeJson('member-17.json'), 200)
|
|
||||||
]));
|
]));
|
||||||
|
|
||||||
$this->setCredentials();
|
$this->setCredentials();
|
||||||
|
|
||||||
Nami::login();
|
Nami::login();
|
||||||
|
|
||||||
$members = Nami::group(103)->members();
|
$member = Nami::group(103)->members()->first();
|
||||||
foreach ($members as $i => $m) {
|
|
||||||
$this->assertSame($values[$i], $m->toArray()[$key]);
|
|
||||||
}
|
|
||||||
|
|
||||||
Http::assertSentCount(6);
|
foreach ($check as $key => $value) {
|
||||||
|
$this->assertSame($value, $member->toArray()[$key]);
|
||||||
|
}
|
||||||
|
Http::assertSentCount(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -1,75 +1,81 @@
|
||||||
|
<?php $json = json_decode('{
|
||||||
|
"jungpfadfinder": null,
|
||||||
|
"mglType": "Mitglied",
|
||||||
|
"geschlecht": "männlich",
|
||||||
|
"staatsangehoerigkeit": "deutsch",
|
||||||
|
"ersteTaetigkeitId": null,
|
||||||
|
"ersteUntergliederung": "Wölfling",
|
||||||
|
"emailVertretungsberechtigter": "testp@example.com",
|
||||||
|
"lastUpdated": "2020-06-28 02:15:24",
|
||||||
|
"ersteTaetigkeit": null,
|
||||||
|
"nameZusatz": "addrz",
|
||||||
|
"id": 16,
|
||||||
|
"staatsangehoerigkeitId": 1054,
|
||||||
|
"version": 58,
|
||||||
|
"sonst01": false,
|
||||||
|
"sonst02": false,
|
||||||
|
"spitzname": "spitz1",
|
||||||
|
"landId": 100,
|
||||||
|
"staatsangehoerigkeitText": "deutsch",
|
||||||
|
"gruppierungId": 103,
|
||||||
|
"mglTypeId": "MITGLIED",
|
||||||
|
"beitragsart": "Voller Beitrag",
|
||||||
|
"nachname": "Nach1",
|
||||||
|
"eintrittsdatum": "2005-05-01 00:00:00",
|
||||||
|
"rover": null,
|
||||||
|
"region": "Nordrhein-Westfalen (Deutschland)",
|
||||||
|
"status": "Aktiv",
|
||||||
|
"konfession": null,
|
||||||
|
"fixBeitrag": null,
|
||||||
|
"konfessionId": 1,
|
||||||
|
"zeitschriftenversand": true,
|
||||||
|
"pfadfinder": null,
|
||||||
|
"telefon3": "+11111",
|
||||||
|
"kontoverbindung":
|
||||||
|
{
|
||||||
|
"id": null,
|
||||||
|
"institut": null,
|
||||||
|
"bankleitzahl": null,
|
||||||
|
"kontonummer": null,
|
||||||
|
"iban": null,
|
||||||
|
"bic": null,
|
||||||
|
"kontoinhaber": null,
|
||||||
|
"mitgliedsNummer": null,
|
||||||
|
"zahlungsKonditionId": null,
|
||||||
|
"zahlungsKondition": null
|
||||||
|
},
|
||||||
|
"geschlechtId": 19,
|
||||||
|
"land": "Deutschland",
|
||||||
|
"email": "test@example.com",
|
||||||
|
"telefon1": "+49888",
|
||||||
|
"woelfling": null,
|
||||||
|
"telefon2": "+49176",
|
||||||
|
"strasse": "straße 1",
|
||||||
|
"vorname": "Max",
|
||||||
|
"mitgliedsNummer": 12345,
|
||||||
|
"gruppierung": "Solingen-Wald, Silva 100105",
|
||||||
|
"austrittsDatum": "",
|
||||||
|
"ort": "SG",
|
||||||
|
"ersteUntergliederungId": null,
|
||||||
|
"wiederverwendenFlag": false,
|
||||||
|
"regionId": 10,
|
||||||
|
"geburtsDatum": "1991-06-20 00:00:00",
|
||||||
|
"stufe": "Wölfling",
|
||||||
|
"genericField1": "",
|
||||||
|
"genericField2": "",
|
||||||
|
"telefax": "+55111",
|
||||||
|
"beitragsartId": 1,
|
||||||
|
"plz": "12345"
|
||||||
|
}', true);
|
||||||
|
|
||||||
|
if (data_get($data, 'data')) {
|
||||||
|
$json = array_merge($json, data_get($data, 'data'));
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
{
|
{
|
||||||
"success": true,
|
"success": true,
|
||||||
"data":
|
"data": <?php echo json_encode($json) ?>,
|
||||||
{
|
|
||||||
"jungpfadfinder": null,
|
|
||||||
"mglType": "Mitglied",
|
|
||||||
"geschlecht": "männlich",
|
|
||||||
"staatsangehoerigkeit": "deutsch",
|
|
||||||
"ersteTaetigkeitId": null,
|
|
||||||
"ersteUntergliederung": "Wölfling",
|
|
||||||
"emailVertretungsberechtigter": "testp@example.com",
|
|
||||||
"lastUpdated": "2020-06-28 02:15:24",
|
|
||||||
"ersteTaetigkeit": null,
|
|
||||||
"nameZusatz": "addrz",
|
|
||||||
"id": 16,
|
|
||||||
"staatsangehoerigkeitId": 1054,
|
|
||||||
"version": 58,
|
|
||||||
"sonst01": false,
|
|
||||||
"sonst02": false,
|
|
||||||
"spitzname": "spitz1",
|
|
||||||
"landId": 100,
|
|
||||||
"staatsangehoerigkeitText": "deutsch",
|
|
||||||
"gruppierungId": 103,
|
|
||||||
"mglTypeId": "MITGLIED",
|
|
||||||
"beitragsart": "Voller Beitrag",
|
|
||||||
"nachname": "Nach1",
|
|
||||||
"eintrittsdatum": "2005-05-01 00:00:00",
|
|
||||||
"rover": null,
|
|
||||||
"region": "Nordrhein-Westfalen (Deutschland)",
|
|
||||||
"status": "Aktiv",
|
|
||||||
"konfession": null,
|
|
||||||
"fixBeitrag": null,
|
|
||||||
"konfessionId": 1,
|
|
||||||
"zeitschriftenversand": true,
|
|
||||||
"pfadfinder": null,
|
|
||||||
"telefon3": "+11111",
|
|
||||||
"kontoverbindung":
|
|
||||||
{
|
|
||||||
"id": null,
|
|
||||||
"institut": null,
|
|
||||||
"bankleitzahl": null,
|
|
||||||
"kontonummer": null,
|
|
||||||
"iban": null,
|
|
||||||
"bic": null,
|
|
||||||
"kontoinhaber": null,
|
|
||||||
"mitgliedsNummer": null,
|
|
||||||
"zahlungsKonditionId": null,
|
|
||||||
"zahlungsKondition": null
|
|
||||||
},
|
|
||||||
"geschlechtId": 19,
|
|
||||||
"land": "Deutschland",
|
|
||||||
"email": "test@example.com",
|
|
||||||
"telefon1": "+49888",
|
|
||||||
"woelfling": null,
|
|
||||||
"telefon2": "+49176",
|
|
||||||
"strasse": "straße 1",
|
|
||||||
"vorname": "Max",
|
|
||||||
"mitgliedsNummer": 12345,
|
|
||||||
"gruppierung": "Solingen-Wald, Silva 100105",
|
|
||||||
"austrittsDatum": "",
|
|
||||||
"ort": "SG",
|
|
||||||
"ersteUntergliederungId": null,
|
|
||||||
"wiederverwendenFlag": false,
|
|
||||||
"regionId": 10,
|
|
||||||
"geburtsDatum": "1991-06-20 00:00:00",
|
|
||||||
"stufe": "Wölfling",
|
|
||||||
"genericField1": "",
|
|
||||||
"genericField2": "",
|
|
||||||
"telefax": "+55111",
|
|
||||||
"beitragsartId": 1,
|
|
||||||
"plz": "12345"
|
|
||||||
},
|
|
||||||
"responseType": null,
|
"responseType": null,
|
||||||
"message": null,
|
"message": null,
|
||||||
"title": null
|
"title": null
|
||||||
|
|
Loading…
Reference in New Issue