Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/ArcClient.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Bearer calls and the OAuth token exchange.
*/
final class ArcClient implements ArcGateway {
final class ArcClient implements ArcGatewayInterface {

public function __construct(
private readonly ClientInterface $http,
Expand Down
2 changes: 1 addition & 1 deletion src/ArcGateway.php → src/ArcGatewayInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Arc HTTP calls used by the connect flow.
*/
interface ArcGateway {
interface ArcGatewayInterface {

/**
* @return array<string, mixed>
Expand Down
12 changes: 6 additions & 6 deletions src/ConnectService.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ final class ConnectService {

public function __construct(
private readonly ConnectionStoreInterface $store,
private readonly ArcGateway $client,
private readonly ArcGatewayInterface $client,
private readonly ArcConfig $config,
private readonly SiteProfile $profile,
private readonly RefreshLock $lock,
private readonly Sleeper $sleeper,
private readonly IdGenerator $ids,
private readonly ContentLinker $links,
private readonly SiteProfileInterface $profile,
private readonly RefreshLockInterface $lock,
private readonly SleeperInterface $sleeper,
private readonly IdGeneratorInterface $ids,
private readonly ContentLinkerInterface $links,
) {}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/ConsentMarkup.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ public function table(array $rows): string {
/**
* Accept, decline, or read-more control.
*
* @param array<string, mixed> $settings
* Settings.
* @param string $action
* accept, decline, or read-more.
* @param array<string, mixed> $settings
* Settings.
* @param string $label
* Button label. Empty uses the saved label.
* @param string $colour
Expand Down
2 changes: 1 addition & 1 deletion src/ContentLinker.php → src/ContentLinkerInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Adds view and edit URLs for paths on this site.
*/
interface ContentLinker {
interface ContentLinkerInterface {

/**
* @param array<int, array<string, mixed>> $blocks
Expand Down
2 changes: 1 addition & 1 deletion src/DrupalContentLinks.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
/**
* Resolves an on-site path to a view URL and an edit URL.
*/
final class DrupalContentLinks implements ContentLinker {
final class DrupalContentLinks implements ContentLinkerInterface {

public function __construct(
private readonly PathValidatorInterface $paths,
Expand Down
2 changes: 1 addition & 1 deletion src/DrupalIdGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Drupal UUID service as an idempotency key source.
*/
final class DrupalIdGenerator implements IdGenerator {
final class DrupalIdGenerator implements IdGeneratorInterface {

public function __construct(
private readonly UuidInterface $uuid,
Expand Down
2 changes: 1 addition & 1 deletion src/DrupalRefreshLock.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
/**
* Drupal lock backend for the refresh rotation.
*/
final class DrupalRefreshLock implements RefreshLock {
final class DrupalRefreshLock implements RefreshLockInterface {

private const NAME = 'pendulum_arc_oauth_refresh';

Expand Down
2 changes: 1 addition & 1 deletion src/DrupalSiteProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* Site name and absolute front URL for the authorize request.
*/
final class DrupalSiteProfile implements SiteProfile {
final class DrupalSiteProfile implements SiteProfileInterface {

public function __construct(
private readonly ConfigFactoryInterface $configFactory,
Expand Down
2 changes: 1 addition & 1 deletion src/DrupalSleeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Waits 200ms between refresh polls.
*/
final class DrupalSleeper implements Sleeper {
final class DrupalSleeper implements SleeperInterface {

public function pause(): void {
usleep(200000);
Expand Down
2 changes: 1 addition & 1 deletion src/IdGenerator.php → src/IdGeneratorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Opaque id for an idempotency key.
*/
interface IdGenerator {
interface IdGeneratorInterface {

public function generate(): string;

Expand Down
2 changes: 1 addition & 1 deletion src/RefreshLock.php → src/RefreshLockInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Single-flight lock around an OAuth refresh.
*/
interface RefreshLock {
interface RefreshLockInterface {

public function claim(): bool;

Expand Down
2 changes: 1 addition & 1 deletion src/SiteProfile.php → src/SiteProfileInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* This install's home URL and site name.
*/
interface SiteProfile {
interface SiteProfileInterface {

/**
* @return array{origin: string, name: string}
Expand Down
2 changes: 1 addition & 1 deletion src/Sleeper.php → src/SleeperInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Pause between refresh-lock polls.
*/
interface Sleeper {
interface SleeperInterface {

public function pause(): void;

Expand Down
26 changes: 13 additions & 13 deletions tests/src/Unit/ConnectFlowTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@

use Drupal\pendulum_arc\ArcApiException;
use Drupal\pendulum_arc\ArcConfig;
use Drupal\pendulum_arc\ArcGateway;
use Drupal\pendulum_arc\ArcGatewayInterface;
use Drupal\pendulum_arc\ConnectService;
use Drupal\pendulum_arc\ConnectionStoreInterface;
use Drupal\pendulum_arc\ContentLinker;
use Drupal\pendulum_arc\IdGenerator;
use Drupal\pendulum_arc\RefreshLock;
use Drupal\pendulum_arc\SiteProfile;
use Drupal\pendulum_arc\Sleeper;
use Drupal\pendulum_arc\ContentLinkerInterface;
use Drupal\pendulum_arc\IdGeneratorInterface;
use Drupal\pendulum_arc\RefreshLockInterface;
use Drupal\pendulum_arc\SiteProfileInterface;
use Drupal\pendulum_arc\SleeperInterface;
use PHPUnit\Framework\TestCase;

/**
Expand Down Expand Up @@ -135,20 +135,20 @@ public function testReconnectUsesTheSavedApiKey(): void {
self::assertSame('arc_live_example_secret', $creds['accessToken']);
}

private function service(ConnectionStoreInterface $store, ArcGateway $client, RefreshLock $lock, ?callable $onPause = NULL): ConnectService {
private function service(ConnectionStoreInterface $store, ArcGatewayInterface $client, RefreshLockInterface $lock, ?callable $onPause = NULL): ConnectService {
return new ConnectService(
$store,
$client,
new ArcConfig('production', ArcConfig::CLIENT_ID, NULL, NULL, FALSE, FALSE),
new class implements SiteProfile {
new class implements SiteProfileInterface {

public function get(): array {
return ['origin' => 'https://example.com/', 'name' => 'Example'];
}

},
$lock,
new class($onPause) implements Sleeper {
new class($onPause) implements SleeperInterface {

public function __construct(private $onPause) {}

Expand All @@ -159,14 +159,14 @@ public function pause(): void {
}

},
new class implements IdGenerator {
new class implements IdGeneratorInterface {

public function generate(): string {
return 'idempotency-key-1';
}

},
new class implements ContentLinker {
new class implements ContentLinkerInterface {

public function linkReportBlocks(array $blocks): array {
return $blocks;
Expand Down Expand Up @@ -283,7 +283,7 @@ public function takeNotice(int $userId): ?array {
/**
* Scores fail once for the old token, then succeed.
*/
final class FakeGateway implements ArcGateway {
final class FakeGateway implements ArcGatewayInterface {

/**
* @var array<int, string> */
Expand Down Expand Up @@ -375,7 +375,7 @@ public function exchangeCode(string $env, string $code, string $verifier, string
/**
* A lock that is either free or already held.
*/
final class MemoryLock implements RefreshLock {
final class MemoryLock implements RefreshLockInterface {

public function __construct(private readonly bool $free) {}

Expand Down
12 changes: 6 additions & 6 deletions tests/src/Unit/ConsentRulesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testDefaultsMatchTheBannerFactory(): void {
self::assertSame([], $settings['cookies']);
}

public function testSanitizeKeepsACookieAndDropsBadValues(): void {
public function testSanitizeKeepsOneCookieAndDropsBadValues(): void {
$clean = ConsentSettings::sanitize(
[
'title' => ' Hello <b>there</b> ',
Expand Down Expand Up @@ -209,7 +209,7 @@ public function testPrintSlotFollowsLayout(): void {
self::assertSame('footer', ConsentSettings::print_slot($settings));
}

public function testASitePathIsKeptAsTheReadMoreLink(): void {
public function testSitePathIsKeptAsTheReadMoreLink(): void {
$clean = ConsentSettings::sanitize(
['read_more_url' => '/privacy'],
''
Expand Down Expand Up @@ -245,7 +245,7 @@ public function testResetRestoresDefaultsAndBumpsTheVersion(): void {
self::assertSame('fresh', $reset['custom_css']);
}

public function testRemovingACatalogRowDismissesItUntilItReturns(): void {
public function testRemovingOneCatalogRowDismissesItUntilItReturns(): void {
$previous = [
['catalog_id' => 'ga'],
['catalog_id' => 'gid'],
Expand Down Expand Up @@ -274,7 +274,7 @@ public function testCatalogMatchesKnownCookiesWithoutSwallowingNeighbours(): voi
);
self::assertSame(
['drupal_session'],
ConsentCatalog::matching_ids(['SESS' . 'example'], [])
ConsentCatalog::matching_ids(['SESSexample'], [])
);
self::assertSame(
['ga'],
Expand All @@ -298,7 +298,7 @@ public function testCatalogMatchesKnownCookiesWithoutSwallowingNeighbours(): voi
);
}

public function testALibraryIdIsNotTreatedAsAUrl(): void {
public function testLibraryIdentifierIsNotTreatedAsUrl(): void {
self::assertTrue(ConsentScripts::is_library_id('google_tag/gtag'));
self::assertFalse(ConsentScripts::is_library_id('https://www.googletagmanager.com/gtag/js'));
self::assertFalse(ConsentScripts::is_library_id('/core/misc/drupal.js'));
Expand Down Expand Up @@ -375,7 +375,7 @@ public function testScriptTagsBlockOnlyOptionalRowsThatAreNotAllowed(): void {
);
}

public function testARequiredMatchWinsOverAnOptionalMatch(): void {
public function testRequiredMatchWinsOverAnOptionalMatch(): void {
$cookies = [
[
'id' => 'cat_ga',
Expand Down
Loading