Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
phpcs fixes
  • Loading branch information
Sebastix committed May 28, 2025
commit 81b2fba257621bae2d4cb66a6a99120c7bd7561b
22 changes: 11 additions & 11 deletions tests/RelayListMetadataTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function testEmptyRelayList(): void
// Replace the Request constructor with our mock
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('The relays property is empty of swentel\nostr\Event\List\RelayListMetadata');

$relayList = new RelayListMetadata(self::TEST_PUBKEY);
$relayList->getRelays();
}
Expand All @@ -52,7 +52,7 @@ public function testGetWriteRelays(): void
]);

$writeRelays = $relayList->getWriteRelays();

$this->assertContains('wss://relay1.com', $writeRelays);
$this->assertNotContains('wss://relay2.com', $writeRelays);
$this->assertContains('wss://relay3.com', $writeRelays);
Expand All @@ -73,7 +73,7 @@ public function testGetReadRelays(): void
]);

$readRelays = $relayList->getReadRelays();

$this->assertContains('wss://relay1.com', $readRelays);
$this->assertNotContains('wss://relay2.com', $readRelays);
$this->assertContains('wss://relay3.com', $readRelays);
Expand All @@ -88,7 +88,7 @@ public function testFallbackRelayQuerying(): void
{
$relayList = $this->createRelayListWithMockData(
[['r', 'wss://fallback-relay.com', 'write']],
true
true,
);

$writeRelays = $relayList->getWriteRelays();
Expand Down Expand Up @@ -127,7 +127,7 @@ private function createRelayListWithMockData(array $tags, bool $useFallback = fa
// Create reflection class to modify private properties
$relayList = new RelayListMetadata(self::TEST_PUBKEY);
$reflection = new \ReflectionClass($relayList);

$relaysProperty = $reflection->getProperty('relays');
$relaysProperty->setAccessible(true);
$relaysProperty->setValue($relayList, $tags);
Expand All @@ -142,12 +142,12 @@ public function testGetKnownRelays(): void
{
$relayList = new RelayListMetadata(self::TEST_PUBKEY);
$reflection = new \ReflectionClass($relayList);

$method = $reflection->getMethod('getKnownRelays');
$method->setAccessible(true);

$knownRelays = $method->invoke($relayList);

$this->assertIsArray($knownRelays);
$this->assertNotEmpty($knownRelays);
foreach ($knownRelays as $relay) {
Expand All @@ -162,16 +162,16 @@ public function testEmptyRelaysThrowExceptions(): void
{
$relayList = new RelayListMetadata(self::TEST_PUBKEY);
$reflection = new \ReflectionClass($relayList);

$relaysProperty = $reflection->getProperty('relays');
$relaysProperty->setAccessible(true);
$relaysProperty->setValue($relayList, []);

$this->expectException(\RuntimeException::class);
$this->expectExceptionMessage('The relays property is empty of swentel\nostr\Event\List\RelayListMetadata');

$relayList->getRelays();
$relayList->getReadRelays();
$relayList->getWriteRelays();
}
}
}