Skip to content

Commit dd9ce1c

Browse files
committed
PHPLIB-680: Topology match should not preempt later checks
1 parent bf9978f commit dd9ce1c

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

tests/UnifiedSpecTests/RunOnRequirement.php

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -92,17 +92,7 @@ public function isSatisfied(string $serverVersion, string $topology, stdClass $s
9292
return false;
9393
}
9494

95-
if (isset($this->topologies)) {
96-
if (in_array($topology, $this->topologies)) {
97-
return true;
98-
}
99-
100-
/* Ensure "sharded-replicaset" is also accepted for topologies that
101-
* only include "sharded" (agnostic about the shard topology) */
102-
if ($topology === self::TOPOLOGY_SHARDED_REPLICASET && in_array(self::TOPOLOGY_SHARDED, $this->topologies)) {
103-
return true;
104-
}
105-
95+
if (isset($this->topologies) && ! $this->isTopologySatisfied($topology)) {
10696
return false;
10797
}
10898

@@ -119,4 +109,19 @@ public function isSatisfied(string $serverVersion, string $topology, stdClass $s
119109

120110
return true;
121111
}
112+
113+
private function isTopologySatisfied(string $topology) : bool
114+
{
115+
if (in_array($topology, $this->topologies)) {
116+
return true;
117+
}
118+
119+
/* Ensure "sharded-replicaset" is also accepted for topologies that
120+
* only include "sharded" (agnostic about the shard topology) */
121+
if ($topology === self::TOPOLOGY_SHARDED_REPLICASET && in_array(self::TOPOLOGY_SHARDED, $this->topologies)) {
122+
return true;
123+
}
124+
125+
return false;
126+
}
122127
}

0 commit comments

Comments
 (0)