Skip to content

Commit b0269f6

Browse files
committed
PHPLIB-1450: Consolidate and improve skipping of tests
1 parent fb7b3ec commit b0269f6

File tree

2 files changed

+61
-156
lines changed

2 files changed

+61
-156
lines changed

tests/UnifiedSpecTests/Operation.php

+31-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,24 @@ final class Operation
8383

8484
private ?string $saveResultAsEntity = null;
8585

86+
private static array $unsupportedOperations = [
87+
self::OBJECT_TEST_RUNNER => [
88+
'assertNumberConnectionsCheckedOut' => 'PHP does not implement CMAP',
89+
'createEntities' => 'createEntities is not implemented (PHPC-1760)',
90+
],
91+
Client::class => [
92+
'clientBulkWrite' => 'clientBulkWrite is not implemented (PHPLIB-847)',
93+
'listDatabaseObjects' => 'listDatabaseObjects is not implemented',
94+
],
95+
Cursor::class => ['iterateOnce' => 'iterateOnce is not implemented (PHPC-1760)'],
96+
Database::class => [
97+
'createCommandCursor' => 'commandCursor API is not yet implemented (PHPLIB-1077)',
98+
'listCollectionObjects' => 'listCollectionObjects is not implemented',
99+
'runCursorCommand' => 'commandCursor API is not yet implemented (PHPLIB-1077)',
100+
],
101+
Collection::class => ['listIndexNames' => 'listIndexNames is not implemented'],
102+
];
103+
86104
public function __construct(stdClass $o, private Context $context)
87105
{
88106
$this->entityMap = $context->getEntityMap();
@@ -166,6 +184,7 @@ private function execute()
166184
$object = $this->entityMap[$this->object];
167185
assertIsObject($object);
168186

187+
$this->skipIfOperationIsNotSupported($object::class);
169188
$this->context->setActiveClient($this->entityMap->getRootClientIdOf($this->object));
170189

171190
switch ($object::class) {
@@ -235,10 +254,6 @@ private function executeForChangeStream(ChangeStream $changeStream)
235254

236255
private function executeForClient(Client $client)
237256
{
238-
if ($this->name === 'clientBulkWrite') {
239-
Assert::markTestSkipped('clientBulkWrite operation is not implemented');
240-
}
241-
242257
$args = $this->prepareArguments();
243258
Util::assertArgumentsBySchema(Client::class, $this->name, $args);
244259

@@ -811,6 +826,8 @@ private function executeForBucket(Bucket $bucket)
811826

812827
private function executeForTestRunner()
813828
{
829+
$this->skipIfOperationIsNotSupported(self::OBJECT_TEST_RUNNER);
830+
814831
$args = $this->prepareArguments();
815832
Util::assertArgumentsBySchema(self::OBJECT_TEST_RUNNER, $this->name, $args);
816833

@@ -963,6 +980,16 @@ private function prepareArguments(): array
963980
return Util::prepareCommonOptions($args);
964981
}
965982

983+
private function skipIfOperationIsNotSupported(string $executingObjectName): void
984+
{
985+
$skipReason = self::$unsupportedOperations[$executingObjectName][$this->name] ?? null;
986+
if (! $skipReason) {
987+
return;
988+
}
989+
990+
Assert::markTestSkipped($skipReason);
991+
}
992+
966993
private static function prepareBulkWriteRequest(stdClass $request): array
967994
{
968995
$request = (array) $request;

0 commit comments

Comments
 (0)