Skip to content

Commit 39cfc02

Browse files
Merge branch '6.4' into 7.2
* 6.4: fix integration tests Check for null parent Nodes in the case of orphaned branches
2 parents 99d7695 + 6caa25d commit 39cfc02

File tree

7 files changed

+57
-111
lines changed

7 files changed

+57
-111
lines changed

.github/workflows/integration-tests.yml

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,25 @@ jobs:
8282
REDIS_MASTER_SET: redis_sentinel
8383
REDIS_SENTINEL_QUORUM: 1
8484
redis-primary:
85-
image: redis:latest
86-
hostname: redis-primary
85+
image: bitnami/redis:latest
8786
ports:
8887
- 16381:6379
89-
88+
env:
89+
ALLOW_EMPTY_PASSWORD: "yes"
90+
REDIS_REPLICATION_MODE: "master"
91+
options: >-
92+
--name=redis-primary
9093
redis-replica:
91-
image: redis:latest
94+
image: bitnami/redis:latest
9295
ports:
9396
- 16382:6379
94-
command: redis-server --slaveof redis-primary 6379
97+
env:
98+
ALLOW_EMPTY_PASSWORD: "yes"
99+
REDIS_REPLICATION_MODE: "slave"
100+
REDIS_MASTER_HOST: redis-primary
101+
REDIS_MASTER_PORT_NUMBER: "6379"
102+
options: >-
103+
--name=redis-replica
95104
memcached:
96105
image: memcached:1.6.5
97106
ports:
@@ -250,7 +259,7 @@ jobs:
250259
REDIS_CLUSTER_HOSTS: 'localhost:7000 localhost:7001 localhost:7002 localhost:7003 localhost:7004 localhost:7005'
251260
REDIS_SENTINEL_HOSTS: 'unreachable-host:26379 localhost:26379 localhost:26379'
252261
REDIS_SENTINEL_SERVICE: redis_sentinel
253-
REDIS_REPLICATION_HOSTS: 'localhost:16381 localhost:16382'
262+
REDIS_REPLICATION_HOSTS: 'localhost:16382 localhost:16381'
254263
MESSENGER_REDIS_DSN: redis://127.0.0.1:7006/messages
255264
MESSENGER_AMQP_DSN: amqp://localhost/%2f/messages
256265
MESSENGER_SQS_DSN: "sqs://localhost:4566/messages?sslmode=disable&poll_timeout=0.01"

src/Symfony/Component/Cache/Tests/Adapter/PredisRedisReplicationAdapterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ public static function setUpBeforeClass(): void
2424
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
2525
}
2626

27-
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][alias]=master', ['class' => \Predis\Client::class, 'prefix' => 'prefix_']);
27+
self::$redis = RedisAdapter::createConnection('redis:?host['.str_replace(' ', ']&host[', $hosts).'][role]=master', ['replication' => 'predis', 'class' => \Predis\Client::class, 'prefix' => 'prefix_']);
2828
}
2929
}

src/Symfony/Component/Cache/Tests/Adapter/PredisReplicationAdapterTest.php

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,22 @@ class PredisReplicationAdapterTest extends AbstractRedisAdapterTestCase
1919
public static function setUpBeforeClass(): void
2020
{
2121
parent::setUpBeforeClass();
22-
self::$redis = new \Predis\Client(array_combine(['host', 'port'], explode(':', getenv('REDIS_HOST')) + [1 => 6379]), ['prefix' => 'prefix_']);
22+
23+
if (!$hosts = getenv('REDIS_REPLICATION_HOSTS')) {
24+
self::markTestSkipped('REDIS_REPLICATION_HOSTS env var is not defined.');
25+
}
26+
27+
$hosts = explode(' ', getenv('REDIS_REPLICATION_HOSTS'));
28+
$lastArrayKey = array_key_last($hosts);
29+
$hostTable = [];
30+
foreach($hosts as $key => $host) {
31+
$hostInformation = array_combine(['host', 'port'], explode(':', $host));
32+
if($lastArrayKey === $key) {
33+
$hostInformation['role'] = 'master';
34+
}
35+
$hostTable[] = $hostInformation;
36+
}
37+
38+
self::$redis = new \Predis\Client($hostTable, ['replication' => 'predis', 'prefix' => 'prefix_']);
2339
}
2440
}

src/Symfony/Component/Cache/Tests/Adapter/PredisTagAwareReplicationAdapterTest.php

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/Symfony/Component/Cache/Tests/Adapter/RedisReplicationAdapterTest.php

Lines changed: 0 additions & 65 deletions
This file was deleted.

src/Symfony/Component/DomCrawler/Crawler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ public function closest(string $selector): ?self
411411

412412
$domNode = $this->getNode(0);
413413

414-
while (\XML_ELEMENT_NODE === $domNode->nodeType) {
414+
while (null !== $domNode && \XML_ELEMENT_NODE === $domNode->nodeType) {
415415
$node = $this->createSubCrawler($domNode);
416416
if ($node->matches($selector)) {
417417
return $node;

src/Symfony/Component/DomCrawler/Tests/AbstractCrawlerTestCase.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1031,6 +1031,29 @@ public function testClosest()
10311031
$this->assertNull($notFound);
10321032
}
10331033

1034+
public function testClosestWithOrphanedNode()
1035+
{
1036+
$html = <<<'HTML'
1037+
<html lang="en">
1038+
<body>
1039+
<div id="foo" class="newFoo ok">
1040+
<div class="lorem1 ko"></div>
1041+
</div>
1042+
</body>
1043+
</html>
1044+
HTML;
1045+
1046+
$crawler = $this->createCrawler($this->getDoctype().$html);
1047+
$foo = $crawler->filter('#foo');
1048+
1049+
$fooNode = $foo->getNode(0);
1050+
1051+
$fooNode->parentNode->replaceChild($fooNode->ownerDocument->createElement('ol'), $fooNode);
1052+
1053+
$body = $foo->closest('body');
1054+
$this->assertNull($body);
1055+
}
1056+
10341057
public function testOuterHtml()
10351058
{
10361059
$html = <<<'HTML'

0 commit comments

Comments
 (0)