Skip to content

Commit df1777a

Browse files
committed
Fix SRAMInterruptFilterTest
1 parent 043e203 commit df1777a

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

docker/docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ services:
6262
- ../theme:/theme
6363

6464
volumes:
65-
eb-mysql-data:
65+
# eb-mysql-data:
6666
eb-mysql-test-data:

tests/library/EngineBlock/Test/Corto/Filter/Command/SRAMInterruptFilterTest.php

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
2020
use OpenConext\EngineBlock\Metadata\Entity\IdentityProvider;
2121
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider;
22+
use OpenConext\EngineBlock\Metadata\MetadataRepository\MetadataRepositoryInterface;
2223
use OpenConext\EngineBlockBundle\Configuration\Feature;
2324
use OpenConext\EngineBlockBundle\Configuration\FeatureConfiguration;
2425
use OpenConext\EngineBlockBundle\Exception\InvalidSbsResponseException;
@@ -34,6 +35,25 @@ class EngineBlock_Test_Corto_Filter_Command_SramInterruptFilterTest extends Test
3435
{
3536
use MockeryPHPUnitIntegration;
3637

38+
/**
39+
* @var ServiceProvider
40+
*/
41+
private $sp;
42+
43+
/**
44+
* @var MetadataRepositoryInterface
45+
*/
46+
private $repository;
47+
48+
public function setUp(): void
49+
{
50+
$this->sp = new ServiceProvider('SP');
51+
52+
$this->repository = Mockery::mock(MetadataRepositoryInterface::class);
53+
$this->repository->shouldReceive('findServiceProviderByEntityId')
54+
->andReturn($this->sp);
55+
}
56+
3757
public function testItDoesNothingIfFeatureFlagNotEnabled(): void
3858
{
3959
$sramFilter = new EngineBlock_Corto_Filter_Command_SRAMInterruptFilter();
@@ -51,6 +71,12 @@ public function testItDoesNothingIfSpDoesNotHaveCollabEnabled(): void
5171
{
5272
$sramFilter = new EngineBlock_Corto_Filter_Command_SRAMInterruptFilter();
5373

74+
$server = Mockery::mock(EngineBlock_Corto_ProxyServer::class);
75+
$server->shouldReceive('getRepository')
76+
->andReturn($this->repository);
77+
78+
$sramFilter->setProxyServer($server);
79+
5480
$request = $this->mockRequest();
5581
$sramFilter->setRequest($request);
5682

@@ -78,6 +104,8 @@ public function testItAddsNonceWhenMessageInterrupt(): void
78104

79105
$server = Mockery::mock(EngineBlock_Corto_ProxyServer::class);
80106
$server->expects('getUrl')->andReturn('https://example.org');
107+
$server->shouldReceive('getRepository')
108+
->andReturn($this->repository);
81109

82110
$sramFilter->setProxyServer($server);
83111

@@ -139,6 +167,8 @@ public function testItAddsSramAttributesOnStatusAuthorized(): void
139167

140168
$server = Mockery::mock(EngineBlock_Corto_ProxyServer::class);
141169
$server->expects('getUrl')->andReturn('https://example.org');
170+
$server->shouldReceive('getRepository')
171+
->andReturn($this->repository);
142172

143173
$sramFilter->setProxyServer($server);
144174

@@ -206,14 +236,15 @@ public function testThrowsEngineBlockExceptionIfPolicyCannotBeChecked()
206236
$sbsClient = $this->mockSbsClient();
207237
$sbsClient->expects('authz')->andThrows(new InvalidSbsResponseException('Server could not be reached.'));
208238

209-
210239
$sramFilter = new EngineBlock_Corto_Filter_Command_SRAMInterruptFilter();
211240

212241
$initialAttributes = ['urn:mace:dir:attribute-def:uid' => ['userIdValue']];
213242
$sramFilter->setResponseAttributes($initialAttributes);
214243

215244
$server = Mockery::mock(EngineBlock_Corto_ProxyServer::class);
216245
$server->expects('getUrl')->andReturn('https://example.org');
246+
$server->shouldReceive('getRepository')
247+
->andReturn($this->repository);
217248

218249
$sramFilter->setProxyServer($server);
219250

0 commit comments

Comments
 (0)