This commit is contained in:
Xes
2025-08-14 22:41:49 +02:00
parent 2de81ccc46
commit 8ce45119b6
39774 changed files with 4309466 additions and 0 deletions

View File

@@ -0,0 +1,66 @@
<?php namespace Tests;
use PHPUnit\Framework\TestCase;
use Mockery;
use Packback\Lti1p3\Interfaces\LtiServiceConnectorInterface;
use Packback\Lti1p3\LtiNamesRolesProvisioningService;
class LtiNamesRolesProvisioningServiceTest extends TestCase
{
public function setUp(): void
{
$this->connector = Mockery::mock(LtiServiceConnectorInterface::class);
}
public function testItInstantiates()
{
$nrps = new LtiNamesRolesProvisioningService($this->connector, []);
$this->assertInstanceOf(LtiNamesRolesProvisioningService::class, $nrps);
}
public function testItGetsMembers()
{
$expected = [ 'members' ];
$nrps = new LtiNamesRolesProvisioningService($this->connector, [
'context_memberships_url' => 'url'
]);
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [],
'body' => [ 'members' => $expected ]
]);
$result = $nrps->getMembers();
$this->assertEquals($expected, $result);
}
public function testItGetsMembersIteratively()
{
$response = [ 'members' ];
$expected = array_merge($response, $response);
$nrps = new LtiNamesRolesProvisioningService($this->connector, [
'context_memberships_url' => 'url'
]);
// First response
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [ 'Link:Something<else>;rel="next"' ],
'body' => [ 'members' => $response ]
]);
// Second response
$this->connector->shouldReceive('makeServiceRequest')
->once()->andReturn([
'headers' => [],
'body' => [ 'members' => $response ]
]);
$result = $nrps->getMembers();
$this->assertEquals($expected, $result);
}
}