2021-08-22 22:49:10 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
|
|
|
|
|
|
|
use Carbon\Carbon;
|
|
|
|
use Illuminate\Support\Facades\Http;
|
|
|
|
use Zoomyboy\LaravelNami\Member;
|
|
|
|
use Zoomyboy\LaravelNami\Nami;
|
|
|
|
use Zoomyboy\LaravelNami\Tests\TestCase;
|
|
|
|
|
|
|
|
class PushMembershipsTest extends TestCase
|
|
|
|
{
|
|
|
|
|
2022-02-18 18:29:02 +01:00
|
|
|
public function test_create_a_membership(): void
|
|
|
|
{
|
2021-08-22 22:49:10 +02:00
|
|
|
Carbon::setTestNow(Carbon::parse('2021-02-03 06:00:00'));
|
2022-02-18 18:29:02 +01:00
|
|
|
Http::fake([
|
2021-08-22 22:49:10 +02:00
|
|
|
'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/16/flist' => Http::response($this->fakeJson('membership-overview.json'), 200),
|
|
|
|
'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/16' => Http::response($this->fakeJson('membership-create.json'), 200),
|
2022-02-18 18:29:02 +01:00
|
|
|
]);
|
2021-08-22 22:49:10 +02:00
|
|
|
|
|
|
|
$member = new Member(['id' => 16]);
|
|
|
|
$id = $member->putMembership([
|
|
|
|
'created_at' => now(),
|
|
|
|
'group_id' => 150,
|
|
|
|
'activity_id' => 56,
|
|
|
|
'subactivity_id' => 89,
|
2021-11-11 23:48:28 +01:00
|
|
|
'starts_at' => now(),
|
2021-08-22 22:49:10 +02:00
|
|
|
]);
|
|
|
|
$this->assertEquals(65, $id);
|
|
|
|
|
2022-02-18 18:29:02 +01:00
|
|
|
Http::assertSentCount(1);
|
2021-08-22 22:49:10 +02:00
|
|
|
|
|
|
|
Http::assertSent(fn ($request) => $request->method() === 'POST'
|
|
|
|
&& $request->url() === 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/16'
|
|
|
|
&& $request['gruppierungId'] === 150
|
|
|
|
&& $request['taetigkeitId'] === 56
|
|
|
|
&& $request['untergliederungId'] === 89
|
|
|
|
&& $request['aktivVon'] === '2021-02-03T00:00:00'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|