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 Zoomyboy\LaravelNami\Fakes\MembershipFake;
|
|
|
|
use Zoomyboy\LaravelNami\Member;
|
|
|
|
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
|
|
|
{
|
2022-03-11 20:20:00 +01:00
|
|
|
public function testGetMembershipsOfAMember(): void
|
2022-02-22 01:31:02 +01:00
|
|
|
{
|
|
|
|
app(MembershipFake::class)
|
2022-03-05 20:22:09 +01:00
|
|
|
->fetches(16, [68])
|
2022-02-22 01:31:02 +01:00
|
|
|
->shows(16, [
|
2022-03-11 20:20:00 +01:00
|
|
|
'id' => 68,
|
2022-02-22 01:31:02 +01:00
|
|
|
]);
|
|
|
|
$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"]
|
|
|
|
*/
|
2022-03-11 20:20:00 +01:00
|
|
|
public function testItGetsNoMembershipsWithNoRights(string $error): void
|
2022-02-22 01:31:02 +01:00
|
|
|
{
|
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
|
|
|
}
|
|
|
|
}
|