<?php

namespace MintyPHP\Tests\Service\Access;

use MintyPHP\Service\Access\PermissionGateway;
use PHPUnit\Framework\TestCase;

class PermissionGatewayTest extends TestCase
{
    public function testUserHasDelegatesToService(): void
    {
        $permissionService = $this->createMock('MintyPHP\\Service\\Access\\PermissionService');
        $permissionService->expects($this->once())
            ->method('userHas')
            ->with(7, 'users.view')
            ->willReturn(true);

        $gateway = new PermissionGateway($permissionService);
        $this->assertTrue($gateway->userHas(7, 'users.view'));
    }

    public function testListPagedDelegatesToService(): void
    {
        $permissionService = $this->createMock('MintyPHP\\Service\\Access\\PermissionService');
        $permissionService->expects($this->once())
            ->method('listPaged')
            ->with(['limit' => 10])
            ->willReturn(['data' => [], 'total' => 0]);

        $gateway = new PermissionGateway($permissionService);
        $this->assertSame(['data' => [], 'total' => 0], $gateway->listPaged(['limit' => 10]));
    }
}
