Skip to content

Commit cb5f43f

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

File tree

2 files changed

+62
-156
lines changed

2 files changed

+62
-156
lines changed

tests/UnifiedSpecTests/Operation.php

+33-4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,26 @@ 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 => [
96+
'iterateOnce' => 'iterateOnce is not implemented (PHPC-1760)',
97+
],
98+
Database::class => [
99+
'createCommandCursor' => 'commandCursor API is not yet implemented (PHPLIB-1077)',
100+
'listCollectionObjects' => 'listCollectionObjects is not implemented',
101+
'runCursorCommand' => 'commandCursor API is not yet implemented (PHPLIB-1077)',
102+
],
103+
Collection::class => ['listIndexNames' => 'listIndexNames is not implemented'],
104+
];
105+
86106
public function __construct(stdClass $o, private Context $context)
87107
{
88108
$this->entityMap = $context->getEntityMap();
@@ -166,6 +186,7 @@ private function execute()
166186
$object = $this->entityMap[$this->object];
167187
assertIsObject($object);
168188

189+
$this->skipIfOperationIsNotSupported($object::class);
169190
$this->context->setActiveClient($this->entityMap->getRootClientIdOf($this->object));
170191

171192
switch ($object::class) {
@@ -235,10 +256,6 @@ private function executeForChangeStream(ChangeStream $changeStream)
235256

236257
private function executeForClient(Client $client)
237258
{
238-
if ($this->name === 'clientBulkWrite') {
239-
Assert::markTestSkipped('clientBulkWrite operation is not implemented');
240-
}
241-
242259
$args = $this->prepareArguments();
243260
Util::assertArgumentsBySchema(Client::class, $this->name, $args);
244261

@@ -811,6 +828,8 @@ private function executeForBucket(Bucket $bucket)
811828

812829
private function executeForTestRunner()
813830
{
831+
$this->skipIfOperationIsNotSupported(self::OBJECT_TEST_RUNNER);
832+
814833
$args = $this->prepareArguments();
815834
Util::assertArgumentsBySchema(self::OBJECT_TEST_RUNNER, $this->name, $args);
816835

@@ -963,6 +982,16 @@ private function prepareArguments(): array
963982
return Util::prepareCommonOptions($args);
964983
}
965984

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

0 commit comments

Comments
 (0)