PHP Cs Fixer
This commit is contained in:
parent
30f4d10364
commit
968f29d4b2
src
Activity.phpApi.php
Authentication
Backend
Casters
Confession.phpCountry.phpData
Exceptions
Fakes
BausteinFake.phpCourseFake.phpFake.phpGroupFake.phpMemberFake.phpMembershipFake.phpSearchFake.phpSubactivityFake.php
Fee.phpGender.phpGroup.phpLogger.phpLoginException.phpMember.phpMemberCollection.phpNami.phpNamiException.phpNationality.phpNullable.phpProviders
Region.phpSubactivity.phptests
|
@ -2,26 +2,29 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Activity extends Model {
|
||||
|
||||
class Activity extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
->mapWithKeys(function ($item, $key) {
|
||||
if ('id' == $key) {
|
||||
return ['id' => $item];
|
||||
}
|
||||
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
return new self($item);
|
||||
}
|
||||
|
||||
public function subactivities() {
|
||||
public function subactivities()
|
||||
{
|
||||
return Nami::subactivitiesOf($this->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
108
src/Api.php
108
src/Api.php
|
@ -2,28 +2,20 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use App\Conf;
|
||||
use App\Nami\Exceptions\TooManyLoginAttemptsException;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Illuminate\Support\Str;
|
||||
use Log;
|
||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||
use Zoomyboy\LaravelNami\Concerns\IsNamiMember;
|
||||
use Zoomyboy\LaravelNami\Data\Baustein;
|
||||
use Zoomyboy\LaravelNami\Data\Course;
|
||||
use Zoomyboy\LaravelNami\Data\Membership;
|
||||
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
||||
use Zoomyboy\LaravelNami\Exceptions\NotAuthenticatedException;
|
||||
use Zoomyboy\LaravelNami\Exceptions\RightException;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
|
||||
class Api {
|
||||
|
||||
class Api
|
||||
{
|
||||
public string $url = 'https://nami.dpsg.de';
|
||||
private Authenticator $authenticator;
|
||||
|
||||
|
@ -32,13 +24,15 @@ class Api {
|
|||
$this->authenticator = $authenticator;
|
||||
}
|
||||
|
||||
public function http(): PendingRequest {
|
||||
public function http(): PendingRequest
|
||||
{
|
||||
return $this->authenticator->http();
|
||||
}
|
||||
|
||||
public function findNr(int $nr): Member
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->find(['mitgliedsNummber' => $nr]);
|
||||
}
|
||||
|
||||
|
@ -48,32 +42,35 @@ class Api {
|
|||
public function find(array $payload): ?Member
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->search($payload)->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $payload
|
||||
*
|
||||
* @return LazyCollection<int, Member>
|
||||
*/
|
||||
public function search(array $payload): LazyCollection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
return LazyCollection::make(function() use ($payload) {
|
||||
|
||||
return LazyCollection::make(function () use ($payload) {
|
||||
$page = 1;
|
||||
while (!isset ($totalEntries) || ($page-1) * 100 + 1 <= $totalEntries) {
|
||||
$start = ($page-1) * 100;
|
||||
while (!isset($totalEntries) || ($page - 1) * 100 + 1 <= $totalEntries) {
|
||||
$start = ($page - 1) * 100;
|
||||
$url = $this->url.'/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode((object) $payload) ?: '{}').'&page='.$page.'&start='.$start.'&limit=100';
|
||||
$response = $this->http()->get($url);
|
||||
if ($response->json()['success'] !== true) {
|
||||
if (true !== $response->json()['success']) {
|
||||
$this->exception('Search failed', $url, $response->json(), ['page' => $page, 'start' => $start]);
|
||||
}
|
||||
$totalEntries = $response->json()['totalEntries'];
|
||||
foreach ($response->json()['data'] as $member) {
|
||||
yield Member::fromNami(collect($member)->mapWithKeys(function($value, $key) {
|
||||
return [ str_replace('entries_', '', (string) $key) => $value ];
|
||||
yield Member::fromNami(collect($member)->mapWithKeys(function ($value, $key) {
|
||||
return [str_replace('entries_', '', (string) $key) => $value];
|
||||
}));
|
||||
}
|
||||
$page++;
|
||||
++$page;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -89,7 +86,7 @@ class Api {
|
|||
];
|
||||
$response = $this->http()->asForm()->post($url, $payload);
|
||||
|
||||
if ($response['success'] !== true) {
|
||||
if (true !== $response['success']) {
|
||||
$this->exception('Deleting member failed', $url, $response->json(), $payload);
|
||||
}
|
||||
}
|
||||
|
@ -109,6 +106,7 @@ class Api {
|
|||
public function membersOf(int $groupId): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection(
|
||||
'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist',
|
||||
'Member fetch failed'
|
||||
|
@ -127,12 +125,12 @@ class Api {
|
|||
$this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->group_id.'/'.$member->id,
|
||||
$payload
|
||||
);
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Update failed', $member->toNami(), $response->json());
|
||||
}
|
||||
} else {
|
||||
$response = $this->http()->post($this->url.'/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$member->group_id, $member->toNami());
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Update failed', $member->toNami(), $response->json());
|
||||
}
|
||||
|
||||
|
@ -152,7 +150,7 @@ class Api {
|
|||
$url = $this->url."/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
$response = $this->http()->post($url, $data->toNami());
|
||||
}
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Update failed', $url, $response->json(), $data->toArray());
|
||||
}
|
||||
|
||||
|
@ -216,20 +214,18 @@ class Api {
|
|||
|
||||
return $this->fetchCollection("/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist", 'Courses fetch failed')
|
||||
->map(fn ($course) => $this->course($memberId, $course['id']))
|
||||
->filter(fn ($course) => $course !== null);
|
||||
->filter(fn ($course) => null !== $course);
|
||||
}
|
||||
|
||||
public function course(int $memberId, int $courseId): ?Course
|
||||
{
|
||||
$single = $this->fetchData("/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}", "Error fetching single course");
|
||||
$single = $this->fetchData("/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}", 'Error fetching single course');
|
||||
|
||||
return $single ? new Course($single) : null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param array<string, mixed> $payload
|
||||
* @return int
|
||||
*/
|
||||
public function createCourse(int $memberId, array $payload): int
|
||||
{
|
||||
|
@ -243,7 +239,7 @@ class Api {
|
|||
];
|
||||
$response = $this->http()->post($url, $payload);
|
||||
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Course creation failed', $url, $response->json(), $payload);
|
||||
}
|
||||
|
||||
|
@ -251,10 +247,7 @@ class Api {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param int $courseId
|
||||
* @param array<string, mixed> $payload
|
||||
* @return void
|
||||
*/
|
||||
public function updateCourse(int $memberId, int $courseId, array $payload): void
|
||||
{
|
||||
|
@ -268,7 +261,7 @@ class Api {
|
|||
];
|
||||
$response = $this->http()->put($url, $payload);
|
||||
|
||||
if (data_get($response->json(), 'success') !== true) {
|
||||
if (true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Course update failed', $url, $response->json(), $payload);
|
||||
}
|
||||
}
|
||||
|
@ -279,7 +272,7 @@ class Api {
|
|||
$url = $this->url."/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}";
|
||||
$response = $this->http()->delete($url);
|
||||
|
||||
if ($response->json() !== null && data_get($response->json(), 'success') !== true) {
|
||||
if (null !== $response->json() && true !== data_get($response->json(), 'success')) {
|
||||
$this->exception('Course deletion failed', $url, $response->json());
|
||||
}
|
||||
}
|
||||
|
@ -292,15 +285,15 @@ class Api {
|
|||
|
||||
Logger::http($url, $response, 'Show member '.$memberId, ['memberId' => $memberId]);
|
||||
|
||||
if($response->json()['success'] === false && Str::startsWith($response['message'], 'Access denied')) {
|
||||
if (false === $response->json()['success'] && Str::startsWith($response['message'], 'Access denied')) {
|
||||
return $this->singleMemberFallback($groupId, $memberId);
|
||||
}
|
||||
|
||||
if($response->json()['success'] === false && Str::startsWith($response['message'], 'Sicherheitsverletzung: Zugriff')) {
|
||||
if (false === $response->json()['success'] && Str::startsWith($response['message'], 'Sicherheitsverletzung: Zugriff')) {
|
||||
return $this->singleMemberFallback($groupId, $memberId);
|
||||
}
|
||||
|
||||
if ($response->json()['success'] !== true) {
|
||||
if (true !== $response->json()['success']) {
|
||||
$this->exception('Fetching member failed', $url, $response->json());
|
||||
}
|
||||
|
||||
|
@ -310,20 +303,22 @@ class Api {
|
|||
public function hasGroup(int $groupId): bool
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
return $this->groups()->search(fn ($group) => $group->id == $groupId) !== false;
|
||||
|
||||
return false !== $this->groups()->search(fn ($group) => $group->id == $groupId);
|
||||
}
|
||||
|
||||
public function groups(int $parentGroupId = null): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
|
||||
return $this->fetchCollection(
|
||||
'/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentGroupId ?: 'root'),
|
||||
'Group fetch failed'
|
||||
)->map(fn ($group) => Group::fromResponse($group, $parentGroupId));
|
||||
}
|
||||
|
||||
public function group(int $groupId): ?Group {
|
||||
public function group(int $groupId): ?Group
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->groups()->first(fn ($group) => $group->id == $groupId);
|
||||
|
@ -332,6 +327,7 @@ class Api {
|
|||
public function subgroupsOf(int $groupId): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->groups($groupId);
|
||||
}
|
||||
|
||||
|
@ -341,8 +337,8 @@ class Api {
|
|||
|
||||
return $this
|
||||
->fetchCollection('/ica/rest/baseadmin/geschlecht', 'Gender fetch failed')
|
||||
->map(fn($gender) => Gender::fromNami($gender))
|
||||
->filter(fn($gender) => !$gender->isNull);
|
||||
->map(fn ($gender) => Gender::fromNami($gender))
|
||||
->filter(fn ($gender) => !$gender->isNull);
|
||||
}
|
||||
|
||||
public function nationalities(): Collection
|
||||
|
@ -369,7 +365,6 @@ class Api {
|
|||
->map(fn ($region) => Region::fromNami($region));
|
||||
}
|
||||
|
||||
|
||||
public function feesOf(int $groupid): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
@ -378,14 +373,16 @@ class Api {
|
|||
->map(fn ($fee) => Fee::fromNami($fee));
|
||||
}
|
||||
|
||||
public function confessions(): Collection {
|
||||
public function confessions(): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection("/ica/rest/baseadmin/konfession", 'Fetch confessions failed')
|
||||
return $this->fetchCollection('/ica/rest/baseadmin/konfession', 'Fetch confessions failed')
|
||||
->map(fn ($confession) => Confession::fromNami($confession));
|
||||
}
|
||||
|
||||
public function activities($groupId) {
|
||||
public function activities($groupId)
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection("/ica/rest/nami/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/{$groupId}", 'Fetch activities failed')
|
||||
|
@ -395,10 +392,11 @@ class Api {
|
|||
public function memberOverviewOf(int $groupId): Collection
|
||||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
return $this->fetchCollection('/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist', 'Fetch membership overview failed')
|
||||
->map(function($member) use ($groupId) {
|
||||
$member = collect($member)->mapWithKeys(function($value, $key) {
|
||||
return [ str_replace('entries_', '', $key) => $value ];
|
||||
->map(function ($member) use ($groupId) {
|
||||
$member = collect($member)->mapWithKeys(function ($value, $key) {
|
||||
return [str_replace('entries_', '', $key) => $value];
|
||||
});
|
||||
$member['gruppierungId'] = $groupId;
|
||||
|
||||
|
@ -410,12 +408,12 @@ class Api {
|
|||
{
|
||||
$this->assertLoggedIn();
|
||||
|
||||
$member = $this->fetchCollection('/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist', 'Fetch single member fallback failed')->first(function($member) use ($memberId) {
|
||||
$member = $this->fetchCollection('/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/flist', 'Fetch single member fallback failed')->first(function ($member) use ($memberId) {
|
||||
return $member['id'] == $memberId;
|
||||
});
|
||||
|
||||
$member = collect($member)->mapWithKeys(function($value, $key) {
|
||||
return [ str_replace('entries_', '', $key) => $value ];
|
||||
$member = collect($member)->mapWithKeys(function ($value, $key) {
|
||||
return [str_replace('entries_', '', $key) => $value];
|
||||
});
|
||||
$member['gruppierungId'] = $groupId;
|
||||
|
||||
|
@ -440,7 +438,7 @@ class Api {
|
|||
{
|
||||
$response = $this->http()->get($this->url.$url);
|
||||
|
||||
if ($response->json() === null) {
|
||||
if (null === $response->json()) {
|
||||
return collect([]);
|
||||
}
|
||||
|
||||
|
@ -452,7 +450,7 @@ class Api {
|
|||
return collect([]);
|
||||
}
|
||||
|
||||
if ($response['success'] === false) {
|
||||
if (false === $response['success']) {
|
||||
$this->exception($error, $url, $response->json());
|
||||
}
|
||||
|
||||
|
@ -463,7 +461,7 @@ class Api {
|
|||
{
|
||||
$response = $this->http()->get($this->url.$url);
|
||||
|
||||
if ($response->json() === null) {
|
||||
if (null === $response->json()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -475,12 +473,10 @@ class Api {
|
|||
return null;
|
||||
}
|
||||
|
||||
if ($response['success'] === false) {
|
||||
if (false === $response['success']) {
|
||||
$this->exception($error, $url, $response->json());
|
||||
}
|
||||
|
||||
return $response['data'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -12,9 +12,10 @@ use Illuminate\Support\Facades\Facade;
|
|||
* @method static void assertNotLoggedInWith(int $mglnr, string $password)
|
||||
* @method static void assertLoggedIn()
|
||||
*/
|
||||
class Auth extends Facade {
|
||||
|
||||
public static function getFacadeAccessor() {
|
||||
class Auth extends Facade
|
||||
{
|
||||
public static function getFacadeAccessor()
|
||||
{
|
||||
return Authenticator::class;
|
||||
}
|
||||
|
||||
|
@ -24,5 +25,4 @@ class Auth extends Facade {
|
|||
|
||||
return $fake;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,14 @@ namespace Zoomyboy\LaravelNami\Authentication;
|
|||
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
|
||||
abstract class Authenticator {
|
||||
|
||||
abstract class Authenticator
|
||||
{
|
||||
abstract public function login(int $mglnr, string $password): self;
|
||||
|
||||
abstract public function http(): PendingRequest;
|
||||
|
||||
abstract public function isLoggedIn(): bool;
|
||||
|
||||
abstract public function refresh(): void;
|
||||
|
||||
protected static string $path = __DIR__.'/../../.cookies';
|
||||
|
@ -17,5 +20,4 @@ abstract class Authenticator {
|
|||
{
|
||||
static::$path = $path;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,15 +2,13 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Authentication;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use GuzzleHttp\Cookie\FileCookieJar;
|
||||
use Illuminate\Http\Client\PendingRequest;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use PHPUnit\Framework\Assert;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
|
||||
class FakeCookie extends Authenticator {
|
||||
|
||||
class FakeCookie extends Authenticator
|
||||
{
|
||||
private array $validAccounts = [];
|
||||
public ?array $invalidAccounts = null;
|
||||
public ?array $authenticated = null;
|
||||
|
@ -21,11 +19,11 @@ class FakeCookie extends Authenticator {
|
|||
fn ($account) => $account['mglnr'] === $mglnr && $account['password'] === $password
|
||||
);
|
||||
|
||||
if ($authenticated !== false) {
|
||||
if (false !== $authenticated) {
|
||||
$this->authenticated = ['mglnr' => $mglnr, 'password' => $password];
|
||||
} else {
|
||||
$e = new LoginException();
|
||||
$e->setResponse(['statusMessage' => "Benutzer nicht gefunden oder Passwort falsch"]);
|
||||
$e->setResponse(['statusMessage' => 'Benutzer nicht gefunden oder Passwort falsch']);
|
||||
|
||||
throw $e;
|
||||
}
|
||||
|
@ -35,7 +33,7 @@ class FakeCookie extends Authenticator {
|
|||
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
return $this->authenticated !== null;
|
||||
return null !== $this->authenticated;
|
||||
}
|
||||
|
||||
public function http(): PendingRequest
|
||||
|
@ -45,12 +43,7 @@ class FakeCookie extends Authenticator {
|
|||
|
||||
/**
|
||||
* Reisters an account that can successfully login with
|
||||
* the given password
|
||||
*
|
||||
* @param int $mglnr
|
||||
* @param string $password
|
||||
*
|
||||
* @return void
|
||||
* the given password.
|
||||
*/
|
||||
public function success(int $mglnr, string $password): void
|
||||
{
|
||||
|
@ -58,12 +51,7 @@ class FakeCookie extends Authenticator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Reisters an account that cannot login with the given password
|
||||
*
|
||||
* @param int $mglnr
|
||||
* @param string $password
|
||||
*
|
||||
* @return void
|
||||
* Reisters an account that cannot login with the given password.
|
||||
*/
|
||||
public function failed(int $mglnr, string $password): void
|
||||
{
|
||||
|
@ -87,7 +75,6 @@ class FakeCookie extends Authenticator {
|
|||
|
||||
public function refresh(): void
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function assertNotLoggedIn(): void
|
||||
|
@ -102,5 +89,4 @@ class FakeCookie extends Authenticator {
|
|||
{
|
||||
Assert::assertTrue($this->isLoggedIn());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,8 +8,8 @@ use Illuminate\Http\Client\PendingRequest;
|
|||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
|
||||
class MainCookie extends Authenticator {
|
||||
|
||||
class MainCookie extends Authenticator
|
||||
{
|
||||
private CookieJar $cookie;
|
||||
private string $url = 'https://nami.dpsg.de';
|
||||
private ?int $mglnr = null;
|
||||
|
@ -33,10 +33,10 @@ class MainCookie extends Authenticator {
|
|||
'Login' => 'API',
|
||||
'redirectTo' => './app.jsp',
|
||||
'username' => $mglnr,
|
||||
'password' => $password
|
||||
'password' => $password,
|
||||
]);
|
||||
|
||||
if ($response->json()['statusCode'] !== 0) {
|
||||
if (0 !== $response->json()['statusCode']) {
|
||||
$e = new LoginException();
|
||||
$e->setResponse($response->json());
|
||||
throw $e;
|
||||
|
@ -49,11 +49,11 @@ class MainCookie extends Authenticator {
|
|||
|
||||
public function isLoggedIn(): bool
|
||||
{
|
||||
if ($this->file() === null) {
|
||||
if (null === $this->file()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return ! $this->isExpired();
|
||||
return !$this->isExpired();
|
||||
}
|
||||
|
||||
public function refresh(): void
|
||||
|
@ -81,7 +81,7 @@ class MainCookie extends Authenticator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the cookie file if it exists
|
||||
* Get the cookie file if it exists.
|
||||
*
|
||||
* @return ?string
|
||||
*/
|
||||
|
@ -97,9 +97,7 @@ class MainCookie extends Authenticator {
|
|||
}
|
||||
|
||||
/**
|
||||
* Loads the cookie for a new request
|
||||
*
|
||||
* @return CookieJar
|
||||
* Loads the cookie for a new request.
|
||||
*/
|
||||
private function load(): CookieJar
|
||||
{
|
||||
|
@ -113,5 +111,4 @@ class MainCookie extends Authenticator {
|
|||
|
||||
return $this->cookie = new CookieJar();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -3,25 +3,17 @@
|
|||
namespace Zoomyboy\LaravelNami\Backend;
|
||||
|
||||
use GuzzleHttp\Promise\PromiseInterface;
|
||||
use GuzzleHttp\Psr7\Response as GuzzleResponse;
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Cache;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Str;
|
||||
use Zoomyboy\LaravelNami\Fakes\CourseFake;
|
||||
use Zoomyboy\LaravelNami\Fakes\Fake;
|
||||
use Zoomyboy\LaravelNami\Fakes\FakeInstance;
|
||||
use Zoomyboy\LaravelNami\Fakes\LoginFake;
|
||||
|
||||
class FakeBackend {
|
||||
|
||||
class FakeBackend
|
||||
{
|
||||
/**
|
||||
* @param int $mitgliedsNr
|
||||
* @param array <string, mixed> $data
|
||||
*/
|
||||
public function addSearch(int $mitgliedsNr, array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data, $mitgliedsNr) {
|
||||
Http::fake(function ($request) use ($data, $mitgliedsNr) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode(json_encode(['mitgliedsNummber' => $mitgliedsNr]) ?: '{}').'&page=1&start=0&limit=100') {
|
||||
$content = [
|
||||
'success' => true,
|
||||
|
@ -29,6 +21,7 @@ class FakeBackend {
|
|||
'responseType' => 'OK',
|
||||
'totalEntries' => 1,
|
||||
];
|
||||
|
||||
return Http::response(json_encode($content) ?: '{}', 200);
|
||||
}
|
||||
});
|
||||
|
@ -41,8 +34,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeNationalities(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/baseadmin/staatsangehoerigkeit') {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/baseadmin/staatsangehoerigkeit' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -68,9 +61,9 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeMembers(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
foreach ($data as $member) {
|
||||
if ($request->url() === $this->singleMemberUrl($member['gruppierungId'], $member['id']) && $request->method() === 'GET') {
|
||||
if ($request->url() === $this->singleMemberUrl($member['gruppierungId'], $member['id']) && 'GET' === $request->method()) {
|
||||
$content = [
|
||||
'success' => true,
|
||||
'data' => $member,
|
||||
|
@ -82,7 +75,7 @@ class FakeBackend {
|
|||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$member['id']}/flist") {
|
||||
$content = [
|
||||
'success' => true,
|
||||
'data' => array_map(function($membership) {
|
||||
'data' => array_map(function ($membership) {
|
||||
return (object) [
|
||||
'entries_aktivVon' => $membership['aktivVon'],
|
||||
'entries_aktivBis' => $membership['aktivBis'],
|
||||
|
@ -91,7 +84,7 @@ class FakeBackend {
|
|||
'entries_taetigkeit' => $membership['taetigkeit'],
|
||||
'entries_untergliederung' => $membership['untergliederung'],
|
||||
];
|
||||
}, $member['memberships'] ?? [])
|
||||
}, $member['memberships'] ?? []),
|
||||
];
|
||||
|
||||
return Http::response(json_encode($content) ?: '{}', 200);
|
||||
|
@ -99,7 +92,7 @@ class FakeBackend {
|
|||
}
|
||||
|
||||
foreach (collect($data)->chunk(100) as $i => $chunk) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode('{}').'&page='.($i+1).'&start='.($i*100).'&limit=100') {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode('{}').'&page='.($i + 1).'&start='.($i * 100).'&limit=100') {
|
||||
return Http::response(json_encode([
|
||||
'success' => true,
|
||||
'totalEntries' => count($data),
|
||||
|
@ -123,8 +116,9 @@ class FakeBackend {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function fakeSingleMembership(int $memberId, int $membershipId, array $data) {
|
||||
Http::fake(function($request) use ($data, $memberId, $membershipId) {
|
||||
public function fakeSingleMembership(int $memberId, int $membershipId, array $data)
|
||||
{
|
||||
Http::fake(function ($request) use ($data, $memberId, $membershipId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$membershipId}") {
|
||||
$content = [
|
||||
'success' => true,
|
||||
|
@ -144,8 +138,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeCountries(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/baseadmin/land') {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/baseadmin/land' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -158,8 +152,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeCourses(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/module/baustein') {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/module/baustein' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -172,8 +166,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeGenders(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/baseadmin/geschlecht') {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/baseadmin/geschlecht' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -186,8 +180,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeRegions(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/baseadmin/region') {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/baseadmin/region' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -196,12 +190,11 @@ class FakeBackend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $groupId
|
||||
* @param array<int, array{name: string, id: int}> $data
|
||||
*/
|
||||
public function fakeActivities(int $groupId, array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data, $groupId) {
|
||||
Http::fake(function ($request) use ($data, $groupId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/{$groupId}") {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
|
@ -215,7 +208,7 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeSubactivities(array $matches): self
|
||||
{
|
||||
Http::fake(function($request) use ($matches) {
|
||||
Http::fake(function ($request) use ($matches) {
|
||||
foreach ($matches as $activityId => $data) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/{$activityId}") {
|
||||
return $this->dataResponse($data);
|
||||
|
@ -227,12 +220,11 @@ class FakeBackend {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $groupId
|
||||
* @param array<int, array{name: string, id: int}> $data
|
||||
*/
|
||||
public function fakeFees(int $groupId, array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data, $groupId) {
|
||||
Http::fake(function ($request) use ($data, $groupId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/namiBeitrag/beitragsartmgl/gruppierung/{$groupId}") {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
|
@ -246,8 +238,8 @@ class FakeBackend {
|
|||
*/
|
||||
public function fakeConfessions(array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($data) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/baseadmin/konfession") {
|
||||
Http::fake(function ($request) use ($data) {
|
||||
if ('https://nami.dpsg.de/ica/rest/baseadmin/konfession' === $request->url()) {
|
||||
return $this->dataResponse($data);
|
||||
}
|
||||
});
|
||||
|
@ -269,5 +261,4 @@ class FakeBackend {
|
|||
|
||||
return Http::response(json_encode($content) ?: '{}', 200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,12 +5,10 @@ namespace Zoomyboy\LaravelNami\Casters;
|
|||
use Carbon\Carbon;
|
||||
use Spatie\DataTransferObject\Caster;
|
||||
|
||||
class CarbonCaster implements Caster {
|
||||
|
||||
class CarbonCaster implements Caster
|
||||
{
|
||||
public function cast(mixed $value): Carbon
|
||||
{
|
||||
return Carbon::parse($value);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -5,14 +5,12 @@ namespace Zoomyboy\LaravelNami\Casters;
|
|||
use Carbon\Carbon;
|
||||
use Spatie\DataTransferObject\Caster;
|
||||
|
||||
class NullableCarbonCaster implements Caster {
|
||||
|
||||
class NullableCarbonCaster implements Caster
|
||||
{
|
||||
public function cast(mixed $value): ?Carbon
|
||||
{
|
||||
return $value
|
||||
? Carbon::parse($value)
|
||||
: null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,15 +2,12 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Casters;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Spatie\DataTransferObject\Caster;
|
||||
|
||||
class NullableString implements Caster {
|
||||
|
||||
class NullableString implements Caster
|
||||
{
|
||||
public function cast(mixed $value): ?string
|
||||
{
|
||||
return $value ?: null;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -2,22 +2,24 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Confession extends Model {
|
||||
|
||||
class Confession extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
->mapWithKeys(function ($item, $key) {
|
||||
if ('id' == $key) {
|
||||
return ['id' => $item];
|
||||
}
|
||||
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
return new self($item);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,18 +2,17 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Country extends Model {
|
||||
|
||||
class Country extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
return new self([
|
||||
'id' => $item['id'],
|
||||
'name' => $item['descriptor']
|
||||
'name' => $item['descriptor'],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,4 +2,6 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Data;
|
||||
|
||||
class Baustein extends EnumData { }
|
||||
class Baustein extends EnumData
|
||||
{
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@ namespace Zoomyboy\LaravelNami\Data;
|
|||
use Spatie\DataTransferObject\Attributes\MapFrom;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
class Course extends DataTransferObject {
|
||||
|
||||
class Course extends DataTransferObject
|
||||
{
|
||||
public int $id;
|
||||
|
||||
#[MapFrom('bausteinId')]
|
||||
|
@ -20,5 +20,4 @@ class Course extends DataTransferObject {
|
|||
|
||||
#[MapFrom('vstgTag')]
|
||||
public string $completedAt;
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,10 @@ namespace Zoomyboy\LaravelNami\Data;
|
|||
use Spatie\DataTransferObject\Attributes\MapFrom;
|
||||
use Spatie\DataTransferObject\DataTransferObject;
|
||||
|
||||
abstract class EnumData extends DataTransferObject {
|
||||
|
||||
abstract class EnumData extends DataTransferObject
|
||||
{
|
||||
public int $id;
|
||||
|
||||
#[MapFrom('descriptor')]
|
||||
public string $name;
|
||||
|
||||
}
|
||||
|
|
|
@ -9,8 +9,8 @@ use Spatie\DataTransferObject\DataTransferObject;
|
|||
use Zoomyboy\LaravelNami\Casters\CarbonCaster;
|
||||
use Zoomyboy\LaravelNami\Casters\NullableCarbonCaster;
|
||||
|
||||
class Membership extends DataTransferObject {
|
||||
|
||||
class Membership extends DataTransferObject
|
||||
{
|
||||
public ?int $id;
|
||||
|
||||
#[MapFrom('gruppierungId')]
|
||||
|
@ -56,6 +56,4 @@ class Membership extends DataTransferObject {
|
|||
'untergliederungId' => data_get($data, 'subactivityId'),
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ use Zoomyboy\LaravelNami\Casters\CarbonCaster;
|
|||
use Zoomyboy\LaravelNami\Casters\NullableCarbonCaster;
|
||||
use Zoomyboy\LaravelNami\Casters\NullableString;
|
||||
|
||||
class MembershipEntry extends DataTransferObject {
|
||||
|
||||
class MembershipEntry extends DataTransferObject
|
||||
{
|
||||
public ?int $id;
|
||||
|
||||
#[MapFrom('entries_gruppierung')]
|
||||
|
@ -31,6 +31,4 @@ class MembershipEntry extends DataTransferObject {
|
|||
#[MapFrom('entries_untergliederung')]
|
||||
#[CastWith(NullableString::class)]
|
||||
public ?string $subactivity;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -4,6 +4,6 @@ namespace Zoomyboy\LaravelNami\Exceptions;
|
|||
|
||||
use Exception;
|
||||
|
||||
class NotAuthenticatedException extends Exception {
|
||||
|
||||
class NotAuthenticatedException extends Exception
|
||||
{
|
||||
}
|
||||
|
|
|
@ -6,5 +6,4 @@ use Exception;
|
|||
|
||||
class RightException extends Exception
|
||||
{
|
||||
|
||||
}
|
||||
|
|
|
@ -2,21 +2,17 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class BausteinFake extends Fake {
|
||||
|
||||
class BausteinFake extends Fake
|
||||
{
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param array $courses
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function fetches(array $courses): self
|
||||
{
|
||||
Http::fake(function($request) use ($courses) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/module/baustein") {
|
||||
Http::fake(function ($request) use ($courses) {
|
||||
if ('https://nami.dpsg.de/ica/rest/module/baustein' === $request->url()) {
|
||||
return $this->collection(collect($courses));
|
||||
}
|
||||
});
|
||||
|
@ -26,13 +22,12 @@ class BausteinFake extends Fake {
|
|||
|
||||
public function failsToFetch(): self
|
||||
{
|
||||
Http::fake(function($request) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/module/baustein") {
|
||||
Http::fake(function ($request) {
|
||||
if ('https://nami.dpsg.de/ica/rest/module/baustein' === $request->url()) {
|
||||
return $this->errorResponse('error');
|
||||
}
|
||||
});
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,27 +2,23 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class CourseFake extends Fake {
|
||||
|
||||
class CourseFake extends Fake
|
||||
{
|
||||
private array $defaults = [
|
||||
'bausteinId' => 506,
|
||||
'veranstalter' => 'KJA',
|
||||
'vstgName' => 'eventname',
|
||||
'vstgTag' => '2021-11-12 00:00:00'
|
||||
'vstgTag' => '2021-11-12 00:00:00',
|
||||
];
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param array<int> $ids
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function fetches(int $memberId, array $ids): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $ids) {
|
||||
Http::fake(function ($request) use ($memberId, $ids) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist") {
|
||||
return $this->collection(collect($ids)->map(fn ($id) => ['id' => $id]));
|
||||
}
|
||||
|
@ -33,7 +29,7 @@ class CourseFake extends Fake {
|
|||
|
||||
public function failsFetchingWithHtml(int $memberId): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId) {
|
||||
Http::fake(function ($request) use ($memberId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist") {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
|
@ -43,14 +39,11 @@ class CourseFake extends Fake {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param array<string, mixed> $data
|
||||
*
|
||||
* @return self
|
||||
*/
|
||||
public function shows(int $memberId, array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $data) {
|
||||
Http::fake(function ($request) use ($memberId, $data) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$data['id']}") {
|
||||
return $this->dataResponse(array_merge($this->defaults, $data));
|
||||
}
|
||||
|
@ -61,7 +54,7 @@ class CourseFake extends Fake {
|
|||
|
||||
public function failsShowing(int $memberId, int $courseId, string $error = 'Error'): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId, $error) {
|
||||
Http::fake(function ($request) use ($memberId, $courseId, $error) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}") {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
|
@ -72,7 +65,7 @@ class CourseFake extends Fake {
|
|||
|
||||
public function failsShowingWithHtml(int $memberId, int $courseId): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
Http::fake(function ($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}") {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
|
@ -83,8 +76,8 @@ class CourseFake extends Fake {
|
|||
|
||||
public function createsSuccessfully(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}" && $request->method() === 'POST') {
|
||||
Http::fake(function ($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}" && 'POST' === $request->method()) {
|
||||
return $this->idResponse($courseId);
|
||||
}
|
||||
});
|
||||
|
@ -92,8 +85,8 @@ class CourseFake extends Fake {
|
|||
|
||||
public function updatesSuccessfully(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'PUT') {
|
||||
Http::fake(function ($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && 'PUT' === $request->method()) {
|
||||
return Http::response([
|
||||
'data' => $courseId,
|
||||
'responseType' => 'OK',
|
||||
|
@ -105,8 +98,8 @@ class CourseFake extends Fake {
|
|||
|
||||
public function deletesSuccessfully(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'DELETE') {
|
||||
Http::fake(function ($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && 'DELETE' === $request->method()) {
|
||||
return Http::response([
|
||||
'data' => null,
|
||||
'responseType' => 'OK',
|
||||
|
@ -118,8 +111,8 @@ class CourseFake extends Fake {
|
|||
|
||||
public function failsDeleting(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'DELETE') {
|
||||
Http::fake(function ($request) use ($memberId, $courseId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && 'DELETE' === $request->method()) {
|
||||
return Http::response([
|
||||
'data' => null,
|
||||
'responseType' => 'NOK',
|
||||
|
@ -131,31 +124,30 @@ class CourseFake extends Fake {
|
|||
|
||||
public function failsCreating(int $memberId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId) {
|
||||
Http::fake(function ($request) use ($memberId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}") {
|
||||
return $this->errorResponse("Unexpected Error javaEx");
|
||||
return $this->errorResponse('Unexpected Error javaEx');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function failsUpdating(int $memberId, int $courseId, string $error = "Error"): void
|
||||
public function failsUpdating(int $memberId, int $courseId, string $error = 'Error'): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $courseId, $error) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && $request->method() === 'PUT') {
|
||||
Http::fake(function ($request) use ($memberId, $courseId, $error) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}" && 'PUT' === $request->method()) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function assertCreated(int $memberId, array $payload): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $payload) {
|
||||
Http::assertSent(function ($request) use ($memberId, $payload) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}"
|
||||
&& $request->method() === 'POST'
|
||||
&& 'POST' === $request->method()
|
||||
&& data_get($request, 'bausteinId') === $payload['bausteinId']
|
||||
&& data_get($request, 'veranstalter') === $payload['veranstalter']
|
||||
&& data_get($request, 'vstgName') === $payload['vstgName']
|
||||
|
@ -164,15 +156,13 @@ class CourseFake extends Fake {
|
|||
}
|
||||
|
||||
/**
|
||||
* @param int $memberId
|
||||
* @param int $courseId
|
||||
* @param array<string, mixed> $payload
|
||||
*/
|
||||
public function assertUpdated(int $memberId, int $courseId, array $payload): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $courseId, $payload) {
|
||||
Http::assertSent(function ($request) use ($memberId, $courseId, $payload) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/${courseId}"
|
||||
&& $request->method() === 'PUT'
|
||||
&& 'PUT' === $request->method()
|
||||
&& data_get($request, 'bausteinId') === $payload['bausteinId']
|
||||
&& data_get($request, 'veranstalter') === $payload['veranstalter']
|
||||
&& data_get($request, 'vstgName') === $payload['vstgName']
|
||||
|
@ -182,26 +172,25 @@ class CourseFake extends Fake {
|
|||
|
||||
public function assertDeleted(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $courseId) {
|
||||
Http::assertSent(function ($request) use ($memberId, $courseId) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/${courseId}"
|
||||
&& $request->method() === 'DELETE';
|
||||
&& 'DELETE' === $request->method();
|
||||
});
|
||||
}
|
||||
|
||||
public function assertFetched(int $memberId): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId) {
|
||||
Http::assertSent(function ($request) use ($memberId) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/flist"
|
||||
&& $request->method() === 'GET';
|
||||
&& 'GET' === $request->method();
|
||||
});
|
||||
}
|
||||
|
||||
public function assertFetchedSingle(int $memberId, int $courseId): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $courseId) {
|
||||
Http::assertSent(function ($request) use ($memberId, $courseId) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/mitglied-ausbildung/filtered-for-navigation/mitglied/mitglied/{$memberId}/{$courseId}"
|
||||
&& $request->method() === 'GET';
|
||||
&& 'GET' === $request->method();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ use GuzzleHttp\Promise\PromiseInterface;
|
|||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
abstract class Fake {
|
||||
|
||||
abstract class Fake
|
||||
{
|
||||
public function errorResponse(string $error): PromiseInterface
|
||||
{
|
||||
return Http::response(json_encode([
|
||||
|
@ -45,5 +45,4 @@ abstract class Fake {
|
|||
{
|
||||
return Http::response('<html></html>');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,11 +2,10 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class GroupFake extends Fake {
|
||||
|
||||
class GroupFake extends Fake
|
||||
{
|
||||
public function fetches(?int $parent = null, array $data): self
|
||||
{
|
||||
$this->fakeResponse($parent, $data);
|
||||
|
@ -17,7 +16,7 @@ class GroupFake extends Fake {
|
|||
public function failsToFetch(int $parentId = null, ?string $error = 'wrong message'): void
|
||||
{
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root');
|
||||
Http::fake(function($request) use ($url, $error) {
|
||||
Http::fake(function ($request) use ($url, $error) {
|
||||
if ($request->url() === $url) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
|
@ -27,7 +26,7 @@ class GroupFake extends Fake {
|
|||
public function failsToFetchWithoutJson(int $parentId = null, ?string $error = 'wrong message'): void
|
||||
{
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root');
|
||||
Http::fake(function($request) use ($url, $error) {
|
||||
Http::fake(function ($request) use ($url) {
|
||||
if ($request->url() === $url) {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
|
@ -37,7 +36,7 @@ class GroupFake extends Fake {
|
|||
private function fakeResponse(?int $parentId = null, array $data): void
|
||||
{
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.($parentId ?: 'root');
|
||||
Http::fake(function($request) use ($data, $url) {
|
||||
Http::fake(function ($request) use ($data, $url) {
|
||||
if ($request->url() === $url) {
|
||||
return Http::response(json_encode([
|
||||
'success' => true,
|
||||
|
@ -50,15 +49,15 @@ class GroupFake extends Fake {
|
|||
|
||||
public function assertRootFetched(): void
|
||||
{
|
||||
Http::assertSent(fn ($request) => $request->url() === 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root'
|
||||
&& $request->method() === 'GET'
|
||||
Http::assertSent(fn ($request) => 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' === $request->url()
|
||||
&& 'GET' === $request->method()
|
||||
);
|
||||
}
|
||||
|
||||
public function assertFetched(int $id): void
|
||||
{
|
||||
Http::assertSent(fn ($request) => $request->url() === 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/'.$id
|
||||
&& $request->method() === 'GET'
|
||||
&& 'GET' === $request->method()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -69,5 +68,4 @@ class GroupFake extends Fake {
|
|||
'descriptor' => $group['name'],
|
||||
])->values()->toArray();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class MemberFake extends Fake {
|
||||
|
||||
class MemberFake extends Fake
|
||||
{
|
||||
public function fetchFails(int $groupId, int $memberId, string $error = 'wrong message'): void
|
||||
{
|
||||
Http::fake(function($request) use ($groupId, $memberId, $error) {
|
||||
Http::fake(function ($request) use ($groupId, $memberId, $error) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
});
|
||||
|
@ -19,14 +18,12 @@ class MemberFake extends Fake {
|
|||
|
||||
public function shows(int $groupId, int $memberId, array $data): void
|
||||
{
|
||||
Http::fake(function($request) use ($groupId, $memberId, $data) {
|
||||
Http::fake(function ($request) use ($groupId, $memberId, $data) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/'.$groupId.'/'.$memberId;
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->dataResponse(array_merge([
|
||||
|
||||
], $data));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,15 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class MembershipFake extends Fake {
|
||||
|
||||
class MembershipFake extends Fake
|
||||
{
|
||||
public function fetches(int $memberId, array $membershipIds): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $membershipIds) {
|
||||
Http::fake(function ($request) use ($memberId, $membershipIds) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/flist';
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->collection(collect($membershipIds)->map(function ($membership) {
|
||||
return [
|
||||
...[
|
||||
|
@ -22,7 +21,7 @@ class MembershipFake extends Fake {
|
|||
'id' => 55,
|
||||
'entries_gruppierung' => '::group::',
|
||||
],
|
||||
...(is_array($membership) ? $membership : ['id' => $membership])
|
||||
...(is_array($membership) ? $membership : ['id' => $membership]),
|
||||
];
|
||||
}));
|
||||
}
|
||||
|
@ -33,9 +32,9 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function failsFetching(int $memberId, string $error = 'Error'): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $error) {
|
||||
Http::fake(function ($request) use ($memberId, $error) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/flist';
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
});
|
||||
|
@ -45,9 +44,9 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function failsFetchingWithHtml(int $memberId): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId) {
|
||||
Http::fake(function ($request) use ($memberId) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/flist';
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
});
|
||||
|
@ -57,19 +56,19 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function shows(int $memberId, array $data): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $data) {
|
||||
Http::fake(function ($request) use ($memberId, $data) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/'.$data['id'];
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->dataResponse(array_merge([
|
||||
"id" => 68,
|
||||
"gruppierung" => "Diözesanleitung Köln 100000",
|
||||
"gruppierungId" => 103,
|
||||
"taetigkeit" => "ReferentIn",
|
||||
"taetigkeitId" => 33,
|
||||
"untergliederung" => "Pfadfinder",
|
||||
"untergliederungId" => 55,
|
||||
"aktivVon" => "2017-02-11 00:00:00",
|
||||
"aktivBis" => "2017-03-11 00:00:00"
|
||||
'id' => 68,
|
||||
'gruppierung' => 'Diözesanleitung Köln 100000',
|
||||
'gruppierungId' => 103,
|
||||
'taetigkeit' => 'ReferentIn',
|
||||
'taetigkeitId' => 33,
|
||||
'untergliederung' => 'Pfadfinder',
|
||||
'untergliederungId' => 55,
|
||||
'aktivVon' => '2017-02-11 00:00:00',
|
||||
'aktivBis' => '2017-03-11 00:00:00',
|
||||
], $data));
|
||||
}
|
||||
});
|
||||
|
@ -79,9 +78,9 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function failsShowing(int $memberId, int $membershipId, ?string $error = 'Error'): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $membershipId, $error) {
|
||||
Http::fake(function ($request) use ($memberId, $membershipId, $error) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/'.$membershipId;
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
});
|
||||
|
@ -91,9 +90,9 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function failsShowingWithHtml(int $memberId, int $membershipId): self
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $membershipId) {
|
||||
Http::fake(function ($request) use ($memberId, $membershipId) {
|
||||
$url = 'https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/'.$memberId.'/'.$membershipId;
|
||||
if ($request->url() === $url && $request->method() === 'GET') {
|
||||
if ($request->url() === $url && 'GET' === $request->method()) {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
});
|
||||
|
@ -103,24 +102,24 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function assertFetched(int $memberId): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId) {
|
||||
Http::assertSent(function ($request) use ($memberId) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/flist"
|
||||
&& $request->method() === 'GET';
|
||||
&& 'GET' === $request->method();
|
||||
});
|
||||
}
|
||||
|
||||
public function assertFetchedSingle(int $memberId, int $membershipId): void
|
||||
{
|
||||
Http::assertSent(function($request) use ($memberId, $membershipId) {
|
||||
Http::assertSent(function ($request) use ($memberId, $membershipId) {
|
||||
return $request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}/{$membershipId}"
|
||||
&& $request->method() === 'GET';
|
||||
&& 'GET' === $request->method();
|
||||
});
|
||||
}
|
||||
|
||||
public function createsSuccessfully(int $memberId, int $membershipId): void
|
||||
{
|
||||
Http::fake(function($request) use ($memberId, $membershipId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}" && $request->method() === 'POST') {
|
||||
Http::fake(function ($request) use ($memberId, $membershipId) {
|
||||
if ($request->url() === "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}" && 'POST' === $request->method()) {
|
||||
return $this->idResponse($membershipId);
|
||||
}
|
||||
});
|
||||
|
@ -128,9 +127,9 @@ class MembershipFake extends Fake {
|
|||
|
||||
public function assertCreated(int $memberId, array $payload): void
|
||||
{
|
||||
$url = "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
$url = "https://nami.dpsg.de/ica/rest/nami/zugeordnete-taetigkeiten/filtered-for-navigation/gruppierung-mitglied/mitglied/{$memberId}";
|
||||
Http::assertSent(function ($request) use ($url, $payload) {
|
||||
if ($request->url() !== $url || $request->method() !== 'POST') {
|
||||
if ($request->url() !== $url || 'POST' !== $request->method()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -150,5 +149,4 @@ class MembershipFake extends Fake {
|
|||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,18 +2,16 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SearchFake extends Fake {
|
||||
|
||||
class SearchFake extends Fake
|
||||
{
|
||||
public function fetchFails(int $page, int $start, ?string $error = 'wrong message'): void
|
||||
{
|
||||
Http::fake(function($request) use ($error, $page, $start) {
|
||||
Http::fake(function ($request) use ($error, $page, $start) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/search-multi/result-list?searchedValues='.rawurlencode('{}').'&page='.$page.'&start='.$start.'&limit=100') {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,14 +2,13 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Fakes;
|
||||
|
||||
use Illuminate\Http\Client\Response;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
|
||||
class SubactivityFake extends Fake {
|
||||
|
||||
class SubactivityFake extends Fake
|
||||
{
|
||||
public function fetchFails(int $activityId, ?string $error = 'wrong message'): void
|
||||
{
|
||||
Http::fake(function($request) use ($activityId, $error) {
|
||||
Http::fake(function ($request) use ($activityId, $error) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activityId) {
|
||||
return $this->errorResponse($error);
|
||||
}
|
||||
|
@ -18,11 +17,10 @@ class SubactivityFake extends Fake {
|
|||
|
||||
public function fetchFailsWithoutJson(int $activityId): void
|
||||
{
|
||||
Http::fake(function($request) use ($activityId) {
|
||||
Http::fake(function ($request) use ($activityId) {
|
||||
if ($request->url() === 'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/'.$activityId) {
|
||||
return $this->htmlResponse();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
11
src/Fee.php
11
src/Fee.php
|
@ -2,20 +2,19 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Fee extends Model {
|
||||
|
||||
class Fee extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
$name = preg_replace('/DPSG Bundesverband 000000 \((.*?) - VERBANDSBEITRAG\)/', '\\1', $item['descriptor']);
|
||||
|
||||
return new self([
|
||||
'name' => $name,
|
||||
'id' => $item['id']
|
||||
'id' => $item['id'],
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,26 +2,27 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Gender extends Model implements Nullable {
|
||||
|
||||
class Gender extends Model implements Nullable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function getNullValue() {
|
||||
public static function getNullValue()
|
||||
{
|
||||
return 23;
|
||||
}
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
return new self([
|
||||
'id' => $item['id'],
|
||||
'name' => ucfirst($item['descriptor'])
|
||||
'name' => ucfirst($item['descriptor']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getIsNullAttribute() {
|
||||
public function getIsNullAttribute()
|
||||
{
|
||||
return $this->id == self::getNullValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,9 @@ namespace Zoomyboy\LaravelNami;
|
|||
|
||||
use Illuminate\Contracts\Support\Arrayable;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
|
||||
class Group implements Arrayable {
|
||||
|
||||
class Group implements Arrayable
|
||||
{
|
||||
public string $name;
|
||||
public int $id;
|
||||
public ?int $parentId;
|
||||
|
@ -41,44 +40,50 @@ class Group implements Arrayable {
|
|||
return $this;
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
return [ 'id' => $this->id, 'name' => $this->name, 'parent_id' => $this->parentId ];
|
||||
public function toArray()
|
||||
{
|
||||
return ['id' => $this->id, 'name' => $this->name, 'parent_id' => $this->parentId];
|
||||
}
|
||||
|
||||
public function subgroups() {
|
||||
public function subgroups()
|
||||
{
|
||||
return Nami::subgroupsOf($this->id);
|
||||
}
|
||||
|
||||
public function fees() {
|
||||
public function fees()
|
||||
{
|
||||
return Nami::feesOf($this->id);
|
||||
}
|
||||
|
||||
public function members(): MemberCollection {
|
||||
public function members(): MemberCollection
|
||||
{
|
||||
$members = Nami::membersOf($this->id);
|
||||
|
||||
return MemberCollection::make(function() use ($members) {
|
||||
return MemberCollection::make(function () use ($members) {
|
||||
foreach ($members as $member) {
|
||||
yield $this->member($member['id']);
|
||||
}
|
||||
});
|
||||
return new MemberCollection(Nami::membersOf($this->id)->map(function($member) {
|
||||
|
||||
return new MemberCollection(Nami::membersOf($this->id)->map(function ($member) {
|
||||
return $this->member($member['id']);
|
||||
}));
|
||||
}
|
||||
|
||||
public function member(int $id): Member {
|
||||
public function member(int $id): Member
|
||||
{
|
||||
return Member::fromNami(Nami::member($this->id, $id));
|
||||
}
|
||||
|
||||
public function memberOverview(): Collection
|
||||
{
|
||||
return Nami::memberOverviewOf($this->id)->map(function($member) {
|
||||
return Nami::memberOverviewOf($this->id)->map(function ($member) {
|
||||
return Member::fromNami($member);
|
||||
});
|
||||
}
|
||||
|
||||
public function activities(): Collection {
|
||||
public function activities(): Collection
|
||||
{
|
||||
return Nami::activities($this->id);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,36 +4,44 @@ namespace Zoomyboy\LaravelNami;
|
|||
|
||||
use Log;
|
||||
|
||||
class Logger {
|
||||
public $errors = [ 404, 403, 401, 500 ];
|
||||
class Logger
|
||||
{
|
||||
public $errors = [404, 403, 401, 500];
|
||||
private $response;
|
||||
private $title;
|
||||
public $options;
|
||||
private $url;
|
||||
|
||||
public static function http($url, $response, $title, $options) {
|
||||
public static function http($url, $response, $title, $options)
|
||||
{
|
||||
$logger = new static($url, $response, $title, $options);
|
||||
|
||||
return $logger->fromHttp();
|
||||
}
|
||||
|
||||
public function __construct($url, $response, $title, $options) {
|
||||
public function __construct($url, $response, $title, $options)
|
||||
{
|
||||
$this->url = $url;
|
||||
$this->response = $response;
|
||||
$this->title = $title;
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
public function fromHttp() {
|
||||
if (is_null($level = $this->level())) { return $this; }
|
||||
public function fromHttp()
|
||||
{
|
||||
if (is_null($level = $this->level())) {
|
||||
return $this;
|
||||
}
|
||||
Log::{$level}($this->title, array_merge([
|
||||
'url' => $this->url,
|
||||
'response' => $this->response->body(),
|
||||
'json' => $this->response->json()
|
||||
'json' => $this->response->json(),
|
||||
], $this->options));
|
||||
}
|
||||
|
||||
public function level() {
|
||||
return in_array($this->response->status(), $this->errors) || $this->response['success'] == false
|
||||
public function level()
|
||||
{
|
||||
return in_array($this->response->status(), $this->errors) || false == $this->response['success']
|
||||
? 'error'
|
||||
: null;
|
||||
}
|
||||
|
|
|
@ -5,15 +5,16 @@ namespace Zoomyboy\LaravelNami;
|
|||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class LoginException extends \Exception {
|
||||
|
||||
const TOO_MANY_FAILED_LOGINS = 1;
|
||||
const WRONG_CREDENTIALS = 2;
|
||||
class LoginException extends \Exception
|
||||
{
|
||||
public const TOO_MANY_FAILED_LOGINS = 1;
|
||||
public const WRONG_CREDENTIALS = 2;
|
||||
|
||||
public $response;
|
||||
public $reason = null;
|
||||
|
||||
public function setResponse($response) {
|
||||
public function setResponse($response)
|
||||
{
|
||||
if (Str::startsWith($response['statusMessage'], 'Die höchste Anzahl von Login-Versuchen wurde erreicht')) {
|
||||
$this->setReason(self::TOO_MANY_FAILED_LOGINS);
|
||||
}
|
||||
|
@ -30,7 +31,8 @@ class LoginException extends \Exception {
|
|||
throw ValidationException::withMessages(['nami' => 'NaMi Login fehlgeschlagen.']);
|
||||
}
|
||||
|
||||
public function setReason($reason) {
|
||||
public function setReason($reason)
|
||||
{
|
||||
$this->reason = $reason;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,18 +5,17 @@ namespace Zoomyboy\LaravelNami;
|
|||
use Carbon\Carbon;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Collection;
|
||||
use Illuminate\Support\LazyCollection;
|
||||
use Zoomyboy\LaravelNami\Data\Membership;
|
||||
use Zoomyboy\LaravelNami\Exceptions\RightException;
|
||||
|
||||
class Member extends Model {
|
||||
|
||||
class Member extends Model
|
||||
{
|
||||
public $timestamps = false;
|
||||
|
||||
public $geschlechtMaps = [
|
||||
'männlich' => 19,
|
||||
'weiblich' => 20,
|
||||
'keine Angabe' => 23
|
||||
'keine Angabe' => 23,
|
||||
];
|
||||
|
||||
protected static $overviewAttributes = [
|
||||
|
@ -63,11 +62,12 @@ class Member extends Model {
|
|||
{
|
||||
$item = collect($item)
|
||||
->only(array_keys(static::$overviewAttributes))
|
||||
->mapWithKeys(function($item, $key) {
|
||||
return [ data_get(static::$overviewAttributes, $key, $key) => $item ];
|
||||
->mapWithKeys(function ($item, $key) {
|
||||
return [data_get(static::$overviewAttributes, $key, $key) => $item];
|
||||
})
|
||||
->toArray();
|
||||
return (new self($item));
|
||||
|
||||
return new self($item);
|
||||
}
|
||||
|
||||
public static function fromAttributes(array $attributes): self
|
||||
|
@ -129,12 +129,14 @@ class Member extends Model {
|
|||
return $this->attributes['gender_id'] == Gender::getNullValue() ? null : $this->attributes['gender_id'];
|
||||
}
|
||||
|
||||
public function setGeschlechtTextAttribute($v) {
|
||||
public function setGeschlechtTextAttribute($v)
|
||||
{
|
||||
$this->attributes['gender_id'] = data_get($this->geschlechtMaps, $v, null);
|
||||
}
|
||||
|
||||
public function setAttribute($key, $value) {
|
||||
if (in_array($key, $this->nullable) && $value === '') {
|
||||
public function setAttribute($key, $value)
|
||||
{
|
||||
if (in_array($key, $this->nullable) && '' === $value) {
|
||||
return parent::setAttribute($key, null);
|
||||
}
|
||||
|
||||
|
@ -166,12 +168,12 @@ class Member extends Model {
|
|||
]);
|
||||
}
|
||||
|
||||
public function membership($id): ?Membership {
|
||||
public function membership($id): ?Membership
|
||||
{
|
||||
try {
|
||||
return Membership::fromNami(Nami::membership($this->id, $id));
|
||||
} catch (RightException $e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,14 +4,14 @@ namespace Zoomyboy\LaravelNami;
|
|||
|
||||
use Illuminate\Support\LazyCollection;
|
||||
|
||||
class MemberCollection extends LazyCollection {
|
||||
|
||||
public static function fromOverview($items) {
|
||||
class MemberCollection extends LazyCollection
|
||||
{
|
||||
public static function fromOverview($items)
|
||||
{
|
||||
$self = new self($items);
|
||||
|
||||
return $self->map(function($item) {
|
||||
return $self->map(function ($item) {
|
||||
return Member::fromOverview($item);
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
10
src/Nami.php
10
src/Nami.php
|
@ -9,8 +9,10 @@ use Illuminate\Support\Facades\Facade;
|
|||
* @method static bool isLoggedIn()
|
||||
* @method static \Zoomyboy\LaravelNami\Api fake()
|
||||
*/
|
||||
class Nami extends Facade {
|
||||
|
||||
protected static function getFacadeAccessor() { return 'nami.api'; }
|
||||
|
||||
class Nami extends Facade
|
||||
{
|
||||
protected static function getFacadeAccessor()
|
||||
{
|
||||
return 'nami.api';
|
||||
}
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@
|
|||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\Validation\ValidationException;
|
||||
|
||||
class NamiException extends \Exception {
|
||||
|
||||
class NamiException extends \Exception
|
||||
{
|
||||
private array $data;
|
||||
private array $response;
|
||||
private string $requestUrl;
|
||||
|
@ -52,8 +51,8 @@ class NamiException extends \Exception {
|
|||
|
||||
public function outputToConsole(Command $command): void
|
||||
{
|
||||
$command->info("Request URL: ".$this->requestUrl);
|
||||
$command->info("response: ".json_encode($this->response));
|
||||
$command->info('Request URL: '.$this->requestUrl);
|
||||
$command->info('response: '.json_encode($this->response));
|
||||
$command->info($this->getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,24 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Nationality extends Model {
|
||||
|
||||
class Nationality extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
->mapWithKeys(function ($item, $key) {
|
||||
if ('id' == $key) {
|
||||
return ['id' => $item];
|
||||
}
|
||||
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
return new self($item);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,10 +2,9 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
interface Nullable {
|
||||
|
||||
interface Nullable
|
||||
{
|
||||
public function getIsNullAttribute();
|
||||
|
||||
public static function getNullValue();
|
||||
|
||||
}
|
||||
|
|
|
@ -2,28 +2,23 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Providers;
|
||||
|
||||
use GuzzleHttp\Client as GuzzleClient;
|
||||
use GuzzleHttp\Cookie\CookieJarInterface;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||
use Zoomyboy\LaravelNami\Authentication\MainCookie;
|
||||
use Zoomyboy\LaravelNami\Backend\LiveBackend;
|
||||
use Zoomyboy\LaravelNami\Cookies\CacheCookie;
|
||||
|
||||
class NamiServiceProvider extends ServiceProvider
|
||||
{
|
||||
public function boot()
|
||||
{
|
||||
//
|
||||
}
|
||||
|
||||
public function register() {
|
||||
$this->app->singleton(Authenticator::class, function() {
|
||||
public function register()
|
||||
{
|
||||
$this->app->singleton(Authenticator::class, function () {
|
||||
return app(MainCookie::class);
|
||||
});
|
||||
$this->app->bind('nami.api', function() {
|
||||
$this->app->bind('nami.api', function () {
|
||||
return app(Api::class);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -2,27 +2,27 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Zoomyboy\LaravelNami\Nullable;
|
||||
|
||||
class Region extends Model implements Nullable {
|
||||
|
||||
class Region extends Model implements Nullable
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function getNullValue() {
|
||||
public static function getNullValue()
|
||||
{
|
||||
return 23;
|
||||
}
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
return new self([
|
||||
'id' => $item['id'],
|
||||
'name' => preg_replace('/\s*\(.*?\)/', '', $item['descriptor'])
|
||||
'name' => preg_replace('/\s*\(.*?\)/', '', $item['descriptor']),
|
||||
]);
|
||||
}
|
||||
|
||||
public function getIsNullAttribute() {
|
||||
public function getIsNullAttribute()
|
||||
{
|
||||
return $this->id == self::getNullValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,30 +2,34 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Subactivity extends Model {
|
||||
|
||||
class Subactivity extends Model
|
||||
{
|
||||
protected $guarded = [];
|
||||
|
||||
public static function fromNami($item) {
|
||||
public static function fromNami($item)
|
||||
{
|
||||
$item = collect($item)
|
||||
->only(['descriptor', 'id'])
|
||||
->mapWithKeys(function($item,$key) {
|
||||
if ($key == 'id') { return ['id' => $item]; }
|
||||
->mapWithKeys(function ($item, $key) {
|
||||
if ('id' == $key) {
|
||||
return ['id' => $item];
|
||||
}
|
||||
|
||||
return ['name' => $item];
|
||||
})->toArray();
|
||||
|
||||
return (new self($item));
|
||||
return new self($item);
|
||||
}
|
||||
|
||||
public function getNameAttribute() {
|
||||
public function getNameAttribute()
|
||||
{
|
||||
return ucfirst($this->attributes['name']);
|
||||
}
|
||||
|
||||
public function getIsNullAttribute() {
|
||||
public function getIsNullAttribute()
|
||||
{
|
||||
return $this->attributes['id'] == self::getNullValue();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -4,11 +4,12 @@ namespace Zoomyboy\LaravelNami\Tests\Stub;
|
|||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class Member extends Model {
|
||||
|
||||
public $fillable = [ 'firstname', 'nami_id' ];
|
||||
class Member extends Model
|
||||
{
|
||||
public $fillable = ['firstname', 'nami_id'];
|
||||
|
||||
public static function findByNamiId($id) {
|
||||
public static function findByNamiId($id)
|
||||
{
|
||||
return self::where('nami_id', $id)->first();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,22 +2,16 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Zoomyboy\LaravelNami\Api;
|
||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\LaravelNami\Authentication\Authenticator;
|
||||
use Zoomyboy\LaravelNami\Cookies\Cookie;
|
||||
use Zoomyboy\LaravelNami\Cookies\FakeCookie;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\Providers\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\Stub\Member;
|
||||
|
||||
class TestCase extends \Orchestra\Testbench\TestCase
|
||||
{
|
||||
|
||||
public function setUp(): void {
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
$this->setupCookies();
|
||||
|
@ -25,16 +19,19 @@ class TestCase extends \Orchestra\Testbench\TestCase
|
|||
|
||||
protected function getPackageProviders($app)
|
||||
{
|
||||
return [ NamiServiceProvider::class ];
|
||||
return [NamiServiceProvider::class];
|
||||
}
|
||||
|
||||
public function getAnnotations(): array {
|
||||
public function getAnnotations(): array
|
||||
{
|
||||
return [];
|
||||
}
|
||||
|
||||
public function fakeJson(string $file, array $data = []): string {
|
||||
public function fakeJson(string $file, array $data = []): string
|
||||
{
|
||||
ob_start();
|
||||
include(__DIR__.'/json/'.$file);
|
||||
include __DIR__.'/json/'.$file;
|
||||
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
|
@ -66,5 +63,4 @@ class TestCase extends \Orchestra\Testbench\TestCase
|
|||
Authenticator::setPath(__DIR__.'/../.cookies_test');
|
||||
$this->clearCookies();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,18 +2,12 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit\Api;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Zoomyboy\LaravelNami\Data\Membership;
|
||||
use Zoomyboy\LaravelNami\Data\MembershipEntry;
|
||||
use Zoomyboy\LaravelNami\Exceptions\RightException;
|
||||
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class MembershipIndexTest extends TestCase
|
||||
{
|
||||
|
||||
public function testGetMembershipsCount(): void
|
||||
{
|
||||
app(MembershipFake::class)->fetches(6, [10, 11]);
|
||||
|
@ -46,7 +40,6 @@ class MembershipIndexTest extends TestCase
|
|||
$this->assertSame('::unter::', $membership->subactivity);
|
||||
}
|
||||
|
||||
|
||||
public function testStringsCanBeNull(): void
|
||||
{
|
||||
app(MembershipFake::class)
|
||||
|
@ -60,6 +53,4 @@ class MembershipIndexTest extends TestCase
|
|||
$this->assertNull($membership->endsAt);
|
||||
$this->assertNull($membership->subactivity);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,15 +4,12 @@ namespace Zoomyboy\LaravelNami\Tests\Unit\Api;
|
|||
|
||||
use Carbon\Carbon;
|
||||
use Zoomyboy\LaravelNami\Data\Membership;
|
||||
use Zoomyboy\LaravelNami\Exceptions\RightException;
|
||||
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class MembershipTest extends TestCase
|
||||
{
|
||||
|
||||
public function testMembershipIsInstanceOfDto(): void
|
||||
{
|
||||
app(MembershipFake::class)
|
||||
|
@ -67,7 +64,7 @@ class MembershipTest extends TestCase
|
|||
/**
|
||||
* @testWith ["Sicherheitsverletzung: Zugriff auf Rechte Recht (n:2001002 o:2) fehlgeschlagen", "Access denied - no right for requested operation"]
|
||||
*/
|
||||
public function test_it_gets_no_memberships_with_no_rights(string $error): void
|
||||
public function testItGetsNoMembershipsWithNoRights(string $error): void
|
||||
{
|
||||
app(MembershipFake::class)->failsShowing(16, 68, $error);
|
||||
|
||||
|
@ -99,5 +96,4 @@ class MembershipTest extends TestCase
|
|||
'gruppierungId' => 1400,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,27 +2,22 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\LaravelNami\Exceptions\NotAuthenticatedException;
|
||||
use Zoomyboy\LaravelNami\Fakes\BausteinFake;
|
||||
use Zoomyboy\LaravelNami\Fakes\CourseFake;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class BausteinTest extends TestCase
|
||||
{
|
||||
|
||||
public function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
|
||||
Auth::fake();
|
||||
}
|
||||
|
||||
public function test_get_all_courses(): void
|
||||
public function testGetAllCourses(): void
|
||||
{
|
||||
Auth::success(12345, 'secret');
|
||||
app(BausteinFake::class)->fetches([['id' => 788, 'descriptor' => 'abc']]);
|
||||
|
@ -35,7 +30,7 @@ class BausteinTest extends TestCase
|
|||
$this->assertEquals('abc', $courses->first()->name);
|
||||
}
|
||||
|
||||
public function test_throw_exception_when_baustein_fetching_fails(): void
|
||||
public function testThrowExceptionWhenBausteinFetchingFails(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
Auth::success(12345, 'secret');
|
||||
|
@ -43,5 +38,4 @@ class BausteinTest extends TestCase
|
|||
|
||||
Nami::login(12345, 'secret')->courses();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,8 +2,6 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Authentication\Auth;
|
||||
use Zoomyboy\LaravelNami\Exceptions\NotAuthenticatedException;
|
||||
use Zoomyboy\LaravelNami\Fakes\CourseFake;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
|
@ -13,8 +11,7 @@ use Zoomyboy\LaravelNami\Tests\TestCase;
|
|||
|
||||
class CourseTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_courses_of_member(): void
|
||||
public function testGetCoursesOfMember(): void
|
||||
{
|
||||
app(CourseFake::class)
|
||||
->fetches(11111, [788])
|
||||
|
@ -23,7 +20,7 @@ class CourseTest extends TestCase
|
|||
'id' => 788,
|
||||
'veranstalter' => 'KJA',
|
||||
'vstgName' => 'eventname',
|
||||
'vstgTag' => '2021-11-12 00:00:00'
|
||||
'vstgTag' => '2021-11-12 00:00:00',
|
||||
]);
|
||||
|
||||
$course = $this->login()->coursesFor(11111)->first();
|
||||
|
@ -38,7 +35,7 @@ class CourseTest extends TestCase
|
|||
app(CourseFake::class)->assertFetchedSingle(11111, 788);
|
||||
}
|
||||
|
||||
public function test_it_gets_multiple_courses_of_member(): void
|
||||
public function testItGetsMultipleCoursesOfMember(): void
|
||||
{
|
||||
app(CourseFake::class)
|
||||
->fetches(11111, [788, 789])
|
||||
|
@ -50,7 +47,7 @@ class CourseTest extends TestCase
|
|||
$this->assertCount(2, $courses);
|
||||
}
|
||||
|
||||
public function test_return_nothing_when_course_returns_html(): void
|
||||
public function testReturnNothingWhenCourseReturnsHtml(): void
|
||||
{
|
||||
app(CourseFake::class)
|
||||
->fetches(11111, [788, 789])
|
||||
|
@ -62,7 +59,7 @@ class CourseTest extends TestCase
|
|||
$this->assertCount(1, $courses);
|
||||
}
|
||||
|
||||
public function test_return_empty_when_course_index_returns_html(): void
|
||||
public function testReturnEmptyWhenCourseIndexReturnsHtml(): void
|
||||
{
|
||||
app(CourseFake::class)->failsFetchingWithHtml(11111);
|
||||
|
||||
|
@ -71,21 +68,21 @@ class CourseTest extends TestCase
|
|||
$this->assertCount(0, $courses);
|
||||
}
|
||||
|
||||
public function test_it_needs_login_to_get_courses(): void
|
||||
public function testItNeedsLoginToGetCourses(): void
|
||||
{
|
||||
$this->expectException(NotAuthenticatedException::class);
|
||||
|
||||
Nami::coursesFor(11111);
|
||||
}
|
||||
|
||||
public function test_store_a_course(): void
|
||||
public function testStoreACourse(): void
|
||||
{
|
||||
app(CourseFake::class)->createsSuccessfully(123, 999);
|
||||
$this->login()->createCourse(123, [
|
||||
'event_name' => '::event::',
|
||||
'completed_at' => '2021-01-02 00:00:00',
|
||||
'organizer' => '::org::',
|
||||
'course_id' => 456
|
||||
'course_id' => 456,
|
||||
]);
|
||||
|
||||
app(CourseFake::class)->assertCreated(123, [
|
||||
|
@ -96,18 +93,18 @@ class CourseTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_needs_login_to_store_a_course(): void
|
||||
public function testNeedsLoginToStoreACourse(): void
|
||||
{
|
||||
$this->expectException(NotAuthenticatedException::class);
|
||||
Nami::createCourse(123, [
|
||||
'event_name' => '::event::',
|
||||
'completed_at' => '2021-01-02 00:00:00',
|
||||
'organizer' => '::org::',
|
||||
'course_id' => 456
|
||||
'course_id' => 456,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_update_a_course(): void
|
||||
public function testUpdateACourse(): void
|
||||
{
|
||||
app(CourseFake::class)->updatesSuccessfully(123, 999);
|
||||
|
||||
|
@ -128,7 +125,7 @@ class CourseTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_throw_exception_when_course_update_failed(): void
|
||||
public function testThrowExceptionWhenCourseUpdateFailed(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
app(CourseFake::class)->failsUpdating(123, 999);
|
||||
|
@ -142,25 +139,25 @@ class CourseTest extends TestCase
|
|||
]);
|
||||
}
|
||||
|
||||
public function test_it_needs_valid_credentials_to_store_a_course(): void
|
||||
public function testItNeedsValidCredentialsToStoreACourse(): void
|
||||
{
|
||||
$this->expectException(NotAuthenticatedException::class);
|
||||
Nami::createCourse(123, [
|
||||
'event_name' => '::event::',
|
||||
'completed_at' => '2021-01-02 00:00:00',
|
||||
'organizer' => '::org::',
|
||||
'course_id' => 456
|
||||
'course_id' => 456,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_it_throws_login_exception_when_fetching_with_wrong_credentials(): void
|
||||
public function testItThrowsLoginExceptionWhenFetchingWithWrongCredentials(): void
|
||||
{
|
||||
$this->expectException(LoginException::class);
|
||||
|
||||
$this->loginWithWrongCredentials()->coursesFor(11111);
|
||||
}
|
||||
|
||||
public function test_throw_exception_when_storing_failed(): void
|
||||
public function testThrowExceptionWhenStoringFailed(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
app(CourseFake::class)->failsCreating(123);
|
||||
|
@ -169,11 +166,11 @@ class CourseTest extends TestCase
|
|||
'event_name' => '::event::',
|
||||
'completed_at' => '2021-01-02 00:00:00',
|
||||
'organizer' => '::org::',
|
||||
'course_id' => 456
|
||||
'course_id' => 456,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_delete_a_course(): void
|
||||
public function testDeleteACourse(): void
|
||||
{
|
||||
app(CourseFake::class)->deletesSuccessfully(123, 999);
|
||||
|
||||
|
@ -182,12 +179,11 @@ class CourseTest extends TestCase
|
|||
app(CourseFake::class)->assertDeleted(123, 999);
|
||||
}
|
||||
|
||||
public function test_shrow_exception_when_deleting_failed(): void
|
||||
public function testShrowExceptionWhenDeletingFailed(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
app(CourseFake::class)->failsDeleting(123, 999);
|
||||
|
||||
$this->login()->deleteCourse(123, 999);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,22 +2,17 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class GetGroupsTest extends TestCase
|
||||
{
|
||||
|
||||
public string $groupsResponse = '{"success":true,"data":[{"descriptor":"Group","name":"","representedClass":"de.iconcept.nami.entity.org.Gruppierung","id":100}],"responseType":"OK"}';
|
||||
public string $subgroupsResponse = '{ "success": true, "data": [ { "descriptor": "Siebengebirge", "name": "", "representedClass": "de.iconcept.nami.entity.org.Gruppierung", "id": 101300 }, { "descriptor": "Sieg", "name": "", "representedClass": "de.iconcept.nami.entity.org.Gruppierung", "id": 100900 }, { "descriptor": "Sieg", "name": "", "representedClass": "de.iconcept.nami.entity.org.Gruppierung", "id": 100900 }, { "descriptor": "Voreifel", "name": "", "representedClass": "de.iconcept.nami.entity.org.Gruppierung", "id": 101000 } ], "responseType": "OK" }';
|
||||
public string $subsubgroupsResponse = '{ "success": true, "data": [ { "descriptor": "Silva", "name": "", "representedClass": "de.iconcept.nami.entity.org.Gruppierung", "id": 100105 } ], "responseType": "OK" }';
|
||||
|
||||
public function test_get_all_groups(): void
|
||||
public function testGetAllGroups(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
|
@ -26,15 +21,15 @@ class GetGroupsTest extends TestCase
|
|||
$groups = $this->login()->groups();
|
||||
|
||||
$this->assertEquals([
|
||||
['id' => 100, 'name' => 'Group', 'parent_id' => null]
|
||||
['id' => 100, 'name' => 'Group', 'parent_id' => null],
|
||||
], $groups->toArray());
|
||||
Http::assertSent(function($request) {
|
||||
return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root';
|
||||
Http::assertSent(function ($request) {
|
||||
return 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' == $request->url();
|
||||
});
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
public function test_has_group_access(): void
|
||||
public function testHasGroupAccess(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
|
@ -47,11 +42,11 @@ class GetGroupsTest extends TestCase
|
|||
Http::assertSentCount(2);
|
||||
}
|
||||
|
||||
public function test_get_subgroups_for_a_group(): void
|
||||
public function testGetSubgroupsForAGroup(): void
|
||||
{
|
||||
Http::fake([
|
||||
'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/100' => Http::response($this->subgroupsResponse, 200)
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/100' => Http::response($this->subgroupsResponse, 200),
|
||||
]);
|
||||
|
||||
$subgroups = $this->login()->group(100)->subgroups();
|
||||
|
@ -60,16 +55,16 @@ class GetGroupsTest extends TestCase
|
|||
['id' => 101300, 'parent_id' => 100, 'name' => 'Siebengebirge'],
|
||||
['id' => 100900, 'parent_id' => 100, 'name' => 'Sieg'],
|
||||
['id' => 100900, 'parent_id' => 100, 'name' => 'Sieg'],
|
||||
['id' => 101000, 'parent_id' => 100, 'name' => 'Voreifel']
|
||||
['id' => 101000, 'parent_id' => 100, 'name' => 'Voreifel'],
|
||||
], $subgroups->toArray());
|
||||
$subgroups->each(function($group) {
|
||||
$subgroups->each(function ($group) {
|
||||
$this->assertInstanceOf(Group::class, $group);
|
||||
});
|
||||
Http::assertSent(function($request) {
|
||||
return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root';
|
||||
Http::assertSent(function ($request) {
|
||||
return 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' == $request->url();
|
||||
});
|
||||
Http::assertSent(function($request) {
|
||||
return $request->url() == 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/100';
|
||||
Http::assertSent(function ($request) {
|
||||
return 'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/100' == $request->url();
|
||||
});
|
||||
Http::assertSentCount(2);
|
||||
}
|
||||
|
|
|
@ -2,21 +2,18 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
|
||||
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
||||
use Zoomyboy\LaravelNami\Member;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class MembershipTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_memberships_of_a_member(): void
|
||||
public function testGetMembershipsOfAMember(): void
|
||||
{
|
||||
app(MembershipFake::class)
|
||||
->fetches(16, [68])
|
||||
->shows(16, [
|
||||
"id" => 68,
|
||||
'id' => 68,
|
||||
]);
|
||||
$this->login();
|
||||
$member = new Member(['id' => 16]);
|
||||
|
@ -29,7 +26,7 @@ class MembershipTest extends TestCase
|
|||
/**
|
||||
* @testWith ["Access denied - no right for requested operation", "Sicherheitsverletzung: Zugriff auf Rechte Recht (n:2001002 o:2) fehlgeschlagen"]
|
||||
*/
|
||||
public function test_it_gets_no_memberships_with_no_rights(string $error): void
|
||||
public function testItGetsNoMembershipsWithNoRights(string $error): void
|
||||
{
|
||||
app(MembershipFake::class)->failsFetching(16, $error);
|
||||
$this->login();
|
||||
|
@ -39,5 +36,4 @@ class MembershipTest extends TestCase
|
|||
|
||||
$this->assertSame([], $memberships->toArray());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,13 +7,11 @@ use Illuminate\Support\Facades\Http;
|
|||
use Zoomyboy\LaravelNami\Data\Membership;
|
||||
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
||||
use Zoomyboy\LaravelNami\Member;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PushMembershipsTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_create_a_membership(): void
|
||||
public function testCreateAMembership(): void
|
||||
{
|
||||
Carbon::setTestNow(Carbon::parse('2021-02-03 06:00:00'));
|
||||
app(MembershipFake::class)->createsSuccessfully(16, 65);
|
||||
|
@ -36,5 +34,4 @@ class PushMembershipsTest extends TestCase
|
|||
'gruppierungId' => 150,
|
||||
]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,55 +2,49 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Fakes\SubactivityFake;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullActivitiesTest extends TestCase
|
||||
{
|
||||
|
||||
public string $groupsResponse = '{"success":true,"data":[{"descriptor":"Group","name":"","representedClass":"de.iconcept.nami.entity.org.Gruppierung","id":103}],"responseType":"OK"}';
|
||||
|
||||
public function test_get_all_activities(): void
|
||||
public function testGetAllActivities(): void
|
||||
{
|
||||
Http::fake([
|
||||
'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/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/103' => Http::response($this->fakeJson('activities.json'), 200)
|
||||
'https://nami.dpsg.de/ica/rest/nami/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/103' => Http::response($this->fakeJson('activities.json'), 200),
|
||||
]);
|
||||
|
||||
$activities = $this->login()->group(103)->activities();
|
||||
|
||||
$this->assertSame([
|
||||
[ 'name' => 'Ac1', 'id' => 4 ],
|
||||
[ 'name' => 'Ac2', 'id' => 3 ]
|
||||
['name' => 'Ac1', 'id' => 4],
|
||||
['name' => 'Ac2', 'id' => 3],
|
||||
], $activities->toArray());
|
||||
Http::assertSentCount(2);
|
||||
}
|
||||
|
||||
public function test_get_all_subactivities(): void
|
||||
public function testGetAllSubactivities(): void
|
||||
{
|
||||
Http::fake([
|
||||
'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/taetigkeitaufgruppierung/filtered/gruppierung/gruppierung/103' => Http::response($this->fakeJson('activities.json'), 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/4' => Http::response($this->fakeJson('subactivities-4.json'), 200)
|
||||
'https://nami.dpsg.de/ica/rest/nami/untergliederungauftaetigkeit/filtered/untergliederung/taetigkeit/4' => Http::response($this->fakeJson('subactivities-4.json'), 200),
|
||||
]);
|
||||
|
||||
$subactivities = $this->login()->group(103)->activities()->first()->subactivities();
|
||||
|
||||
$this->assertSame([
|
||||
[ 'name' => 'Biber', 'id' => 40 ],
|
||||
[ 'name' => 'Wölfling', 'id' => 30 ]
|
||||
['name' => 'Biber', 'id' => 40],
|
||||
['name' => 'Wölfling', 'id' => 30],
|
||||
], $subactivities->toArray());
|
||||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
public function test_throw_error_when_subactivities_request_fails(): void
|
||||
public function testThrowErrorWhenSubactivitiesRequestFails(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
app(SubactivityFake::class)->fetchFails(4, 'sorry dude');
|
||||
|
@ -58,7 +52,7 @@ class PullActivitiesTest extends TestCase
|
|||
$subactivities = $this->login()->subactivitiesOf(4);
|
||||
}
|
||||
|
||||
public function test_continue_if_subactivities_request_returns_html(): void
|
||||
public function testContinueIfSubactivitiesRequestReturnsHtml(): void
|
||||
{
|
||||
app(SubactivityFake::class)->fetchFailsWithoutJson(4);
|
||||
|
||||
|
@ -66,5 +60,4 @@ class PullActivitiesTest extends TestCase
|
|||
|
||||
$this->assertCount(0, $subactivities);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,30 +2,23 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullConfessionTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_all_confessions(): void
|
||||
public function testGetAllConfessions(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/konfession' => Http::response($this->fakeJson('confession.json'), 200)
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/konfession' => Http::response($this->fakeJson('confession.json'), 200),
|
||||
]);
|
||||
|
||||
$confessions = $this->login()->confessions();
|
||||
|
||||
$this->assertEquals([
|
||||
1 => 'römisch-katholisch'
|
||||
1 => 'römisch-katholisch',
|
||||
], $confessions->pluck('name', 'id')->toArray());
|
||||
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,31 +2,24 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullGenderTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_all_genders(): void
|
||||
public function testGetAllGenders(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/geschlecht' => Http::response($this->fakeJson('genders.json'), 200)
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/geschlecht' => Http::response($this->fakeJson('genders.json'), 200),
|
||||
]);
|
||||
|
||||
$genders = $this->login()->genders();
|
||||
|
||||
$this->assertEquals([
|
||||
19 => 'Männlich',
|
||||
20 => 'Weiblich'
|
||||
20 => 'Weiblich',
|
||||
], $genders->pluck('name', 'id')->toArray());
|
||||
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,14 +2,9 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Fakes\MemberFake;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullMemberTest extends TestCase
|
||||
|
@ -17,46 +12,48 @@ class PullMemberTest extends TestCase
|
|||
public string $groupsResponse = '{"success":true,"data":[{"descriptor":"Group","name":"","representedClass":"de.iconcept.nami.entity.org.Gruppierung","id":103}],"responseType":"OK"}';
|
||||
public string $unauthorizedResponse = '{"success":false,"data":null,"responseType":"EXCEPTION","message":"Access denied - no right for requested operation","title":"Exception"}';
|
||||
|
||||
public function dataProvider(): array {
|
||||
public function dataProvider(): array
|
||||
{
|
||||
return [
|
||||
'firstname' => [ ['vorname' => 'Max'], ['firstname' => 'Max' ] ],
|
||||
'lastname' => [ ['nachname' => 'Nach'], ['lastname' => 'Nach' ] ],
|
||||
'nickname' => [ ['spitzname' => 'spitz1'], ['nickname' => 'spitz1'] ],
|
||||
'nicknameEmpty' => [ ['spitzname' => null], ['nickname' => null] ],
|
||||
'other_country' => [ ['staatsangehoerigkeitText' => 'deutsch'], ['other_country' => 'deutsch'] ],
|
||||
'other_countryEmpty' => [ ['staatsangehoerigkeitText' => ''], ['other_country' => null] ],
|
||||
'address' => [ ['strasse' => 'Straße 1'], ['address' => 'Straße 1'] ],
|
||||
'further_address' => [ ['nameZusatz' => 'addrz'], ['further_address' => 'addrz'] ],
|
||||
'further_addressEmpty' => [ ['nameZusatz' => ''], ['further_address' => null] ],
|
||||
'zip' => [ ['plz' => '12345'], ['zip' => '12345'] ],
|
||||
'location' => [ ['ort' => 'Köln'], ['location' => 'Köln'] ],
|
||||
'main_phone' => [ ['telefon1' => '+49888'], ['main_phone' => '+49888'] ],
|
||||
'mobile_phone' => [ ['telefon2' => '+49176'], ['mobile_phone' => '+49176'] ],
|
||||
'work_phone' => [ ['telefon3' => '+49177'], ['work_phone' => '+49177'] ],
|
||||
'fax' => [ ['telefax' => '+55111'], ['fax' => '+55111'] ],
|
||||
'email' => [ ['email' => 'a@b.de'], ['email' => 'a@b.de'] ],
|
||||
'email_parents' => [ ['emailVertretungsberechtigter' => 'v@b.de'], ['email_parents' => 'v@b.de'] ],
|
||||
'gender_id' => [ ['geschlechtId' => 19], ['gender_id' => 19] ],
|
||||
'gender_idEmpty' => [ ['geschlechtId' => 23], ['gender_id' => null] ],
|
||||
'nationality_id' => [ ['staatsangehoerigkeitId' => 1054], ['nationality_id' => 1054] ],
|
||||
'nationality_idEmpty' => [ ['staatsangehoerigkeitId' => null], ['nationality_id' => null] ],
|
||||
'confession_id' => [ ['konfessionId' => 1], ['confession_id' => 1] ],
|
||||
'confession_idEmpty' => [ ['konfessionId' => null], ['confession_id' => null] ],
|
||||
'birthday' => [ ['geburtsDatum' => "1991-06-20 00:00:00"], ['birthday' => "1991-06-20"] ],
|
||||
'joined_at' => [ ['eintrittsdatum' => "2005-05-01 00:00:00"], ['joined_at' => "2005-05-01"] ],
|
||||
'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] ],
|
||||
'firstname' => [['vorname' => 'Max'], ['firstname' => 'Max']],
|
||||
'lastname' => [['nachname' => 'Nach'], ['lastname' => 'Nach']],
|
||||
'nickname' => [['spitzname' => 'spitz1'], ['nickname' => 'spitz1']],
|
||||
'nicknameEmpty' => [['spitzname' => null], ['nickname' => null]],
|
||||
'other_country' => [['staatsangehoerigkeitText' => 'deutsch'], ['other_country' => 'deutsch']],
|
||||
'other_countryEmpty' => [['staatsangehoerigkeitText' => ''], ['other_country' => null]],
|
||||
'address' => [['strasse' => 'Straße 1'], ['address' => 'Straße 1']],
|
||||
'further_address' => [['nameZusatz' => 'addrz'], ['further_address' => 'addrz']],
|
||||
'further_addressEmpty' => [['nameZusatz' => ''], ['further_address' => null]],
|
||||
'zip' => [['plz' => '12345'], ['zip' => '12345']],
|
||||
'location' => [['ort' => 'Köln'], ['location' => 'Köln']],
|
||||
'main_phone' => [['telefon1' => '+49888'], ['main_phone' => '+49888']],
|
||||
'mobile_phone' => [['telefon2' => '+49176'], ['mobile_phone' => '+49176']],
|
||||
'work_phone' => [['telefon3' => '+49177'], ['work_phone' => '+49177']],
|
||||
'fax' => [['telefax' => '+55111'], ['fax' => '+55111']],
|
||||
'email' => [['email' => 'a@b.de'], ['email' => 'a@b.de']],
|
||||
'email_parents' => [['emailVertretungsberechtigter' => 'v@b.de'], ['email_parents' => 'v@b.de']],
|
||||
'gender_id' => [['geschlechtId' => 19], ['gender_id' => 19]],
|
||||
'gender_idEmpty' => [['geschlechtId' => 23], ['gender_id' => null]],
|
||||
'nationality_id' => [['staatsangehoerigkeitId' => 1054], ['nationality_id' => 1054]],
|
||||
'nationality_idEmpty' => [['staatsangehoerigkeitId' => null], ['nationality_id' => null]],
|
||||
'confession_id' => [['konfessionId' => 1], ['confession_id' => 1]],
|
||||
'confession_idEmpty' => [['konfessionId' => null], ['confession_id' => null]],
|
||||
'birthday' => [['geburtsDatum' => '1991-06-20 00:00:00'], ['birthday' => '1991-06-20']],
|
||||
'joined_at' => [['eintrittsdatum' => '2005-05-01 00:00:00'], ['joined_at' => '2005-05-01']],
|
||||
'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]],
|
||||
];
|
||||
}
|
||||
|
||||
public function overviewDataProvider(): array {
|
||||
public function overviewDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'firstname' => ['firstname', ['Max', 'Jane']],
|
||||
'lastname' => ['lastname', ['Nach1', 'Nach2']],
|
||||
|
@ -73,11 +70,12 @@ class PullMemberTest extends TestCase
|
|||
'joined_at' => ['joined_at', ['2005-05-01', null]],
|
||||
'group_id' => ['group_id', [103, 103]],
|
||||
'mitgliedsnr' => ['mitgliedsnr', [12345, null]],
|
||||
'updated_at' => ['updated_at', ['2020-06-28 02:15:24', '2015-02-03 15:20:07']]
|
||||
'updated_at' => ['updated_at', ['2020-06-28 02:15:24', '2015-02-03 15:20:07']],
|
||||
];
|
||||
}
|
||||
|
||||
public function relationProvider(): array {
|
||||
public function relationProvider(): array
|
||||
{
|
||||
return [
|
||||
'firstname' => ['firstname', ['Max', 'Jane']],
|
||||
];
|
||||
|
@ -86,7 +84,7 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider dataProvider
|
||||
*/
|
||||
public function test_get_a_single_member(array $input, array $check): void
|
||||
public function testGetASingleMember(array $input, array $check): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
|
@ -105,7 +103,7 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider dataProvider
|
||||
*/
|
||||
public function test_get_attribute_of_member_collection(array $input, array $check): void
|
||||
public function testGetAttributeOfMemberCollection(array $input, array $check): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/gruppierungen/filtered-for-navigation/gruppierung/node/root' => Http::response($this->groupsResponse, 200),
|
||||
|
@ -124,11 +122,11 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider overviewDataProvider
|
||||
*/
|
||||
public function test_get_attribute_of_member_overview(string $key, array $values): void
|
||||
public function testGetAttributeOfMemberOverview(string $key, array $values): void
|
||||
{
|
||||
Http::fake([
|
||||
'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),
|
||||
]);
|
||||
|
||||
$members = $this->login()->group(103)->memberOverview();
|
||||
|
@ -142,20 +140,20 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider relationProvider
|
||||
*/
|
||||
public function test_set_relations(string $key, array $values): void
|
||||
public function testSetRelations(string $key, array $values): void
|
||||
{
|
||||
Http::fake([
|
||||
'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/16' => Http::response($this->fakeJson('member-16.json'), 200),
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response($this->fakeJson('member-17.json'), 200)
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/17' => Http::response($this->fakeJson('member-17.json'), 200),
|
||||
]);
|
||||
|
||||
$members = $this->login()->group(103)->members();
|
||||
|
||||
$this->assertSame([
|
||||
16 => $values[0],
|
||||
17 => $values[1]
|
||||
17 => $values[1],
|
||||
], $members->pluck($key, 'id')->toArray());
|
||||
|
||||
Http::assertSentCount(4);
|
||||
|
@ -164,12 +162,12 @@ class PullMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider overviewDataProvider
|
||||
*/
|
||||
public function test_get_a_member_from_overview_with_no_rights(string $key, array $values): void
|
||||
public function testGetAMemberFromOverviewWithNoRights(string $key, array $values): void
|
||||
{
|
||||
Http::fake([
|
||||
'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->unauthorizedResponse, 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),
|
||||
]);
|
||||
|
||||
$member = $this->login()->group(103)->member(16);
|
||||
|
@ -179,12 +177,11 @@ class PullMemberTest extends TestCase
|
|||
Http::assertSentCount(3);
|
||||
}
|
||||
|
||||
public function test_member_fetch_can_fail(): void
|
||||
public function testMemberFetchCanFail(): void
|
||||
{
|
||||
$this->expectException(NamiException::class);
|
||||
app(MemberFake::class)->fetchFails(103, 16);
|
||||
|
||||
$this->login()->member(103, 16);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,30 +2,23 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PullNationalityTest extends TestCase
|
||||
{
|
||||
|
||||
public function test_get_all_nationalities(): void
|
||||
public function testGetAllNationalities(): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/staatsangehoerigkeit' => Http::response($this->fakeJson('nationalities.json'))
|
||||
'https://nami.dpsg.de/ica/rest/baseadmin/staatsangehoerigkeit' => Http::response($this->fakeJson('nationalities.json')),
|
||||
]);
|
||||
|
||||
$nationalities = $this->login()->nationalities();
|
||||
|
||||
$this->assertEquals([
|
||||
['name' => 'deutsch', 'id' => 1054]
|
||||
['name' => 'deutsch', 'id' => 1054],
|
||||
], $nationalities->toArray());
|
||||
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,14 +2,8 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Member;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class PushMemberTest extends TestCase
|
||||
|
@ -33,10 +27,11 @@ class PushMemberTest extends TestCase
|
|||
'joined_at' => '2021-02-02T00:00:00',
|
||||
'birthday' => '2021-02-02',
|
||||
'id' => 17,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
public function dataProvider(): array {
|
||||
public function dataProvider(): array
|
||||
{
|
||||
return [
|
||||
'firstname' => [['firstname' => 'Max'], ['vorname' => 'Max']],
|
||||
'lastname' => [['lastname' => 'Nach1'], ['nachname' => 'Nach1']],
|
||||
|
@ -49,7 +44,8 @@ class PushMemberTest extends TestCase
|
|||
/**
|
||||
* @dataProvider dataProvider
|
||||
*/
|
||||
public function test_push_a_single_member(array $overwrites, array $check): void {
|
||||
public function testPushASingleMember(array $overwrites, array $check): void
|
||||
{
|
||||
Http::fake([
|
||||
'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' => Http::response('{"success": true, "data": {"id": 16}}', 200),
|
||||
]);
|
||||
|
@ -58,8 +54,8 @@ class PushMemberTest extends TestCase
|
|||
$res = Nami::putMember(array_merge($this->attributes[0], $overwrites));
|
||||
$this->assertEquals(16, $res['id']);
|
||||
|
||||
Http::assertSent(function($request) use ($check) {
|
||||
if ($request->url() != 'https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' || $request->method() !== 'PUT') {
|
||||
Http::assertSent(function ($request) use ($check) {
|
||||
if ('https://nami.dpsg.de/ica/rest/nami/mitglied/filtered-for-navigation/gruppierung/gruppierung/103/16' != $request->url() || 'PUT' !== $request->method()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -69,10 +65,9 @@ class PushMemberTest extends TestCase
|
|||
}
|
||||
}
|
||||
|
||||
return $request->method() === 'PUT';
|
||||
return 'PUT' === $request->method();
|
||||
});
|
||||
|
||||
Http::assertSentCount(2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,21 +2,13 @@
|
|||
|
||||
namespace Zoomyboy\LaravelNami\Tests\Unit;
|
||||
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Support\Facades\Config;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Zoomyboy\LaravelNami\Fakes\SearchFake;
|
||||
use Zoomyboy\LaravelNami\Group;
|
||||
use Zoomyboy\LaravelNami\LoginException;
|
||||
use Zoomyboy\LaravelNami\Member;
|
||||
use Zoomyboy\LaravelNami\Nami;
|
||||
use Zoomyboy\LaravelNami\NamiException;
|
||||
use Zoomyboy\LaravelNami\NamiServiceProvider;
|
||||
use Zoomyboy\LaravelNami\Tests\TestCase;
|
||||
|
||||
class SearchTest extends TestCase
|
||||
{
|
||||
|
||||
public array $attributes = [
|
||||
[
|
||||
'firstname' => 'Max',
|
||||
|
@ -32,7 +24,7 @@ class SearchTest extends TestCase
|
|||
'group_id' => 103,
|
||||
'gender_id' => null,
|
||||
'id' => 17,
|
||||
]
|
||||
],
|
||||
];
|
||||
|
||||
public function dataProvider(): array
|
||||
|
@ -42,7 +34,7 @@ class SearchTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
public function test_find_a_member_by_mglnr(): void
|
||||
public function testFindAMemberByMglnr(): void
|
||||
{
|
||||
Http::fake([
|
||||
$this->url(['mitgliedsNummber' => 150]) => Http::response($this->fakeJson('searchResponse.json'), 200),
|
||||
|
@ -51,15 +43,15 @@ class SearchTest extends TestCase
|
|||
$member = $this->login()->findNr(150);
|
||||
|
||||
$this->assertEquals('Philipp', $member->firstname);
|
||||
Http::assertSent(function($request) {
|
||||
Http::assertSent(function ($request) {
|
||||
return $request->url() == $this->url(['mitgliedsNummber' => 150])
|
||||
&& $request->method() == 'GET';
|
||||
&& 'GET' == $request->method();
|
||||
});
|
||||
|
||||
Http::assertSentCount(1);
|
||||
}
|
||||
|
||||
public function test_it_throws_exception_when_search_fails(): void
|
||||
public function testItThrowsExceptionWhenSearchFails(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->expectException(NamiException::class);
|
||||
app(SearchFake::class)->fetchFails($page = 1, $start = 0, 'unknown error');
|
||||
|
@ -73,5 +65,4 @@ class SearchTest extends TestCase
|
|||
|
||||
return "https://nami.dpsg.de/ica/rest/nami/search-multi/result-list?searchedValues={$payload}&page=1&start=0&limit=100";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue