Skip to content

PHPLIB-1080: Spec tests for command events databaseName property #1309

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions .evergreen/config/generated/build/build-php-7.4.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .evergreen/config/generated/build/build-php-8.0.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .evergreen/config/generated/build/build-php-8.1.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .evergreen/config/generated/build/build-php-8.2.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .evergreen/config/generated/build/build-php-8.3.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions .evergreen/config/templates/build/build-extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tasks:
PHP_VERSION: "%phpVersion%"
- func: "compile extension"
vars:
EXTENSION_VERSION: "1.18.0"
EXTENSION_VERSION: "1.19.0"
- func: "upload extension"
- name: "build-php-%phpVersion%-next-stable"
tags: ["build", "php%phpVersion%", "next-stable"]
Expand All @@ -25,7 +25,7 @@ tasks:
PHP_VERSION: "%phpVersion%"
- func: "compile extension"
vars:
EXTENSION_BRANCH: "v1.18"
EXTENSION_BRANCH: "v1.19"
- func: "upload extension"
- name: "build-php-%phpVersion%-next-minor"
tags: ["build", "php%phpVersion%", "next-minor"]
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"php": "^7.4 || ^8.0",
"ext-hash": "*",
"ext-json": "*",
"ext-mongodb": "^1.18.0",
"ext-mongodb": "^1.19.0",
"composer-runtime-api": "^2.0",
"psr/log": "^1.1.4|^2|^3",
"symfony/polyfill-php80": "^1.27",
Expand Down
14 changes: 12 additions & 2 deletions tests/UnifiedSpecTests/EventObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ private function assertCommandStartedEvent(CommandStartedEvent $actual, stdClass

private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdClass $expected, string $message): void
{
Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'hasServiceId', 'hasServerConnectionId']);
Util::assertHasOnlyKeys($expected, ['reply', 'commandName', 'databaseName', 'hasServiceId', 'hasServerConnectionId']);

if (isset($expected->reply)) {
assertIsObject($expected->reply);
Expand All @@ -288,6 +288,11 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC
assertSame($actual->getCommandName(), $expected->commandName, $message . ': commandName matches');
}

if (isset($expected->databaseName)) {
assertIsString($expected->databaseName);
assertSame($actual->getDatabaseName(), $expected->databaseName, $message . ': databaseName matches');
}

if (isset($expected->hasServiceId)) {
assertIsBool($expected->hasServiceId);
assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches');
Expand All @@ -301,13 +306,18 @@ private function assertCommandSucceededEvent(CommandSucceededEvent $actual, stdC

private function assertCommandFailedEvent(CommandFailedEvent $actual, stdClass $expected, string $message): void
{
Util::assertHasOnlyKeys($expected, ['commandName', 'hasServiceId', 'hasServerConnectionId']);
Util::assertHasOnlyKeys($expected, ['commandName', 'databaseName', 'hasServiceId', 'hasServerConnectionId']);

if (isset($expected->commandName)) {
assertIsString($expected->commandName);
assertSame($actual->getCommandName(), $expected->commandName, $message . ': commandName matches');
}

if (isset($expected->databaseName)) {
assertIsString($expected->databaseName);
assertSame($actual->getDatabaseName(), $expected->databaseName, $message . ': databaseName matches');
}

if (isset($expected->hasServiceId)) {
assertIsBool($expected->hasServiceId);
assertSame($actual->getServiceId() !== null, $expected->hasServiceId, $message . ': hasServiceId matches');
Expand Down
13 changes: 9 additions & 4 deletions tests/UnifiedSpecTests/UnifiedTestRunner.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,16 @@ final class UnifiedTestRunner

public const MIN_SCHEMA_VERSION = '1.0';

/* Note: This is necessary to support expectedError.errorResponse from 1.12;
* however, syntax from 1.9, 1.10, and 1.11 has not been fully implemented.
* Syntax for 1.9 is partially implemented (createEntities operation).
/**
* Support for the following schema versions is incomplete:
*
* - 1.9: Only createEntities operation is implemented
* - 1.10: Not implemented
* - 1.11: Not implemented, but CMAP is not applicable
* - 1.13: Not implemented
* - 1.14: Not implemented
*/
public const MAX_SCHEMA_VERSION = '1.12';
public const MAX_SCHEMA_VERSION = '1.15';

private Client $internalClient;

Expand Down