Skip to content

Commit 69670ac

Browse files
committed
fix: convert @dataProvider docblocks to PHP8 attributes in ConsentIntegrationTest
1 parent 2c8ce7e commit 69670ac

7 files changed

Lines changed: 20 additions & 39 deletions

File tree

src/OpenConext/EngineBlockBundle/Authentication/Repository/DbalConsentRepository.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,8 @@ public function storeConsentHash(ConsentStoreParameters $parameters): bool
228228
{
229229
$query = "INSERT INTO consent (hashed_user_id, service_id, attribute_stable, consent_type, consent_date, deleted_at)
230230
VALUES (?, ?, ?, ?, NOW(), '0000-00-00 00:00:00')
231-
ON DUPLICATE KEY UPDATE attribute_stable=VALUES(attribute_stable), consent_type=VALUES(consent_type), consent_date=NOW(), deleted_at='0000-00-00 00:00:00'";
231+
ON DUPLICATE KEY UPDATE attribute_stable=VALUES(attribute_stable),
232+
consent_type=VALUES(consent_type), consent_date=NOW(), deleted_at='0000-00-00 00:00:00'";
232233

233234
try {
234235
$this->connection->executeStatement($query, [

tests/library/EngineBlock/Test/Corto/Model/ConsentIntegrationTest.php

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider;
2828
use OpenConext\EngineBlock\Service\Consent\ConsentHashService;
2929
use OpenConext\EngineBlockBundle\Authentication\Repository\DbalConsentRepository;
30+
use PHPUnit\Framework\Attributes\DataProvider;
3031
use PHPUnit\Framework\TestCase;
3132

3233
class ConsentIntegrationTest extends TestCase
@@ -68,9 +69,7 @@ public function setup(): void
6869
);
6970
}
7071

71-
/**
72-
* @dataProvider consentTypeProvider
73-
*/
72+
#[DataProvider('consentTypeProvider')]
7473
public function test_no_previous_consent_given($consentType)
7574
{
7675
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -92,9 +91,7 @@ public function test_no_previous_consent_given($consentType)
9291
}
9392
}
9493

95-
/**
96-
* @dataProvider consentTypeProvider
97-
*/
94+
#[DataProvider('consentTypeProvider')]
9895
public function test_unstable_previous_consent_given($consentType)
9996
{
10097
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -124,9 +121,7 @@ public function test_unstable_previous_consent_given($consentType)
124121
}
125122
}
126123

127-
/**
128-
* @dataProvider consentTypeProvider
129-
*/
124+
#[DataProvider('consentTypeProvider')]
130125
public function test_stable_consent_given($consentType)
131126
{
132127
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -156,9 +151,7 @@ public function test_stable_consent_given($consentType)
156151
}
157152
}
158153

159-
/**
160-
* @dataProvider consentTypeProvider
161-
*/
154+
#[DataProvider('consentTypeProvider')]
162155
public function test_give_consent_no_unstable_consent_given($consentType)
163156
{
164157
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -187,9 +180,7 @@ public function test_give_consent_no_unstable_consent_given($consentType)
187180
}
188181
}
189182

190-
/**
191-
* @dataProvider consentTypeProvider
192-
*/
183+
#[DataProvider('consentTypeProvider')]
193184
public function test_upgrade_to_stable_consent($consentType)
194185
{
195186
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -213,9 +204,7 @@ public function test_upgrade_to_stable_consent($consentType)
213204
$this->assertNull($this->consent->upgradeAttributeHashFor($serviceProvider, $consentType, ConsentVersion::unstable()));
214205
}
215206

216-
/**
217-
* @dataProvider consentTypeProvider
218-
*/
207+
#[DataProvider('consentTypeProvider')]
219208
public function test_upgrade_to_stable_consent_not_applied_when_stable($consentType)
220209
{
221210
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -228,9 +217,7 @@ public function test_upgrade_to_stable_consent_not_applied_when_stable($consentT
228217
$this->assertNull($this->consent->upgradeAttributeHashFor($serviceProvider, $consentType, ConsentVersion::stable()));
229218
}
230219

231-
/**
232-
* @dataProvider consentTypeProvider
233-
*/
220+
#[DataProvider('consentTypeProvider')]
234221
public function test_upgrade_not_applied_when_no_consent_given($consentType)
235222
{
236223
$serviceProvider = new ServiceProvider("service-provider-entity-id");
@@ -242,9 +229,7 @@ public function test_upgrade_not_applied_when_no_consent_given($consentType)
242229
$this->assertNull($this->consent->upgradeAttributeHashFor($serviceProvider, $consentType, ConsentVersion::notGiven()));
243230
}
244231

245-
/**
246-
* @dataProvider consentTypeProvider
247-
*/
232+
#[DataProvider('consentTypeProvider')]
248233
public function test_upgrade_continues_gracefully_when_attributes_changed($consentType)
249234
{
250235
$serviceProvider = new ServiceProvider("service-provider-entity-id");

tests/library/EngineBlock/Test/Corto/Module/Service/ProcessConsentTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
20+
use OpenConext\EngineBlock\Authentication\Value\ConsentVersion;
2021
use OpenConext\EngineBlock\Metadata\Entity\ServiceProvider;
2122
use OpenConext\EngineBlock\Metadata\MetadataRepository\InMemoryMetadataRepository;
2223
use OpenConext\EngineBlock\Service\AuthenticationStateHelperInterface;
@@ -148,6 +149,7 @@ public function testConsentIsStored()
148149
}
149150

150151
public function testResponseIsSent() {
152+
$this->mockConsent();
151153
$processConsentService = $this->factoryService();
152154

153155
Phake::when($this->proxyServerMock)
@@ -221,7 +223,7 @@ private function mockConsent()
221223
$consentMock = Phake::mock('EngineBlock_Corto_Model_Consent');
222224
Phake::when($consentMock)
223225
->explicitConsentWasGivenFor(Phake::anyParameters())
224-
->thenReturn(false);
226+
->thenReturn(ConsentVersion::notGiven());
225227
Phake::when($this->consentFactoryMock)
226228
->create(Phake::anyParameters())
227229
->thenReturn($consentMock);

tests/library/EngineBlock/Test/Corto/Module/Service/ProvideConsentTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,9 @@ private function mockConsent()
281281
Phake::when($consentMock)
282282
->explicitConsentWasGivenFor(Phake::anyParameters())
283283
->thenReturn(ConsentVersion::notGiven());
284+
Phake::when($consentMock)
285+
->implicitConsentWasGivenFor(Phake::anyParameters())
286+
->thenReturn(ConsentVersion::notGiven());
284287
Phake::when($this->consentFactoryMock)
285288
->create(Phake::anyParameters())
286289
->thenReturn($consentMock);

tests/library/EngineBlock/Test/Saml2/NameIdResolverMock.php

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,9 @@ class EngineBlock_Test_Saml2_NameIdResolverMock extends EngineBlock_Saml2_NameId
2121
private $_serviceProviderUuids = array();
2222
private $_persistentIds = array();
2323

24-
protected function _getUserDirectory()
24+
protected function _getUserUuid($collabPersonId)
2525
{
26-
$mock = new EngineBlock_Test_UserDirectoryMock();
27-
$mock->setUser(
28-
'urn:collab:person:example.edu:mock1',
29-
array(
30-
'collabpersonid' => 'urn:collab:person:example.edu:mock1',
31-
'collabpersonuuid' => '',
32-
)
33-
);
34-
return $mock;
26+
return sha1($collabPersonId);
3527
}
3628

3729
protected function _fetchPersistentId($serviceProviderUuid, $userUuid)

tests/library/EngineBlock/Test/Saml2/NameIdResolverTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,8 +162,6 @@ public function testMetadataOverAuthnRequest()
162162

163163
public function testPersistent(): void
164164
{
165-
$this->markTestSkipped('Fails when switching to other backend, test should not rely on having fixed backend');
166-
167165
// Input
168166
$nameIdFormat = 'urn:oasis:names:tc:SAML:2.0:nameid-format:persistent';
169167
$this->serviceProvider->nameIdFormat = $nameIdFormat;

tests/phpunit.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
<html outputDirectory="../var/log/phpunit/coverage/html"/>
3838
</report>
3939
</coverage>
40-
<source restrictDeprecations="true" restrictNotices="true" restrictWarnings="true" ignoreSuppressionOfDeprecations="true">
40+
<source restrictNotices="true" restrictWarnings="true" ignoreSuppressionOfDeprecations="true" ignoreIndirectDeprecations="true">
4141
<include>
4242
<directory>src</directory>
4343
<directory>library</directory>

0 commit comments

Comments
 (0)