laravel-nami-api/tests/Unit/Member/MembershipTest.php

44 lines
1.2 KiB
PHP
Raw Normal View History

2022-02-22 01:31:02 +01:00
<?php
2022-03-05 20:22:09 +01:00
namespace Zoomyboy\LaravelNami\Tests\Unit\Member;
2022-02-22 01:31:02 +01:00
use Illuminate\Support\Facades\Http;
use Zoomyboy\LaravelNami\Fakes\MembershipFake;
use Zoomyboy\LaravelNami\Member;
use Zoomyboy\LaravelNami\Nami;
use Zoomyboy\LaravelNami\Tests\TestCase;
2022-03-05 20:22:09 +01:00
class MembershipTest extends TestCase
2022-02-22 01:31:02 +01:00
{
public function test_get_memberships_of_a_member(): void
{
app(MembershipFake::class)
2022-03-05 20:22:09 +01:00
->fetches(16, [68])
2022-02-22 01:31:02 +01:00
->shows(16, [
"id" => 68,
]);
$this->login();
$member = new Member(['id' => 16]);
$membership = $member->memberships()->first();
$this->assertEquals(68, $membership->id);
}
/**
* @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
{
2022-03-05 20:22:09 +01:00
app(MembershipFake::class)->failsFetching(16, $error);
2022-02-22 01:31:02 +01:00
$this->login();
$member = new Member(['id' => 16]);
$memberships = $member->memberships();
2022-03-05 20:22:09 +01:00
$this->assertSame([], $memberships->toArray());
2022-02-22 01:31:02 +01:00
}
2022-02-22 01:52:05 +01:00
2022-02-22 01:31:02 +01:00
}