Skip to content

Commit 65bbd42

Browse files
authored
PHPLIB-528, PHPLIB-788: Use Session::isDirty() and update session spec tests (#889)
* PHPLIB-528: Use Session::isDirty() for spec test assertions * PHPLIB-788: Update session spec tests Synced with mongodb/specifications@e11c1e4
1 parent 117108a commit 65bbd42

File tree

9 files changed

+1245
-133
lines changed

9 files changed

+1245
-133
lines changed

.evergreen/config.yml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -608,14 +608,20 @@ axes:
608608
- id: driver-versions
609609
display_name: Driver Version
610610
values:
611+
# TODO: Update to "1.13.0" once PHPC 1.13.0 is released
611612
- id: "oldest-supported"
612-
display_name: "1.12.0"
613+
# display_name: "1.13.0"
614+
display_name: "1.13-dev (master)"
613615
variables:
614-
EXTENSION_VERSION: "1.12.0"
616+
# EXTENSION_VERSION: "1.13.0"
617+
EXTENSION_BRANCH: "master"
618+
# TODO: Update to "1.13.x"/"stable" once PHPC 1.13.0 is released
615619
- id: "latest-stable"
616-
display_name: "1.12.x"
620+
# display_name: "1.13.x"
621+
display_name: "1.13-dev (master)"
617622
variables:
618-
EXTENSION_VERSION: "stable"
623+
# EXTENSION_VERSION: "stable"
624+
EXTENSION_BRANCH: "master"
619625
- id: "latest-dev"
620626
display_name: "1.13-dev (master)"
621627
variables:

.github/workflows/coding-standards.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ jobs:
2020
php-version:
2121
- "7.4"
2222
driver-version:
23-
- "stable"
23+
- "mongodb/mongo-php-driver@master"
2424

2525
steps:
2626
- name: "Checkout"

.github/workflows/tests.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,24 +27,24 @@ jobs:
2727
mongodb-version:
2828
- "4.4"
2929
driver-version:
30-
- "stable"
30+
- "mongodb/mongo-php-driver@master"
3131
topology:
3232
- "server"
3333
include:
3434
- os: "ubuntu-20.04"
3535
php-version: "8.0"
3636
mongodb-version: "5.0"
37-
driver-version: "stable"
37+
driver-version: "mongodb/mongo-php-driver@master"
3838
topology: "server"
3939
- os: "ubuntu-20.04"
4040
php-version: "8.0"
4141
mongodb-version: "4.4"
42-
driver-version: "stable"
42+
driver-version: "mongodb/mongo-php-driver@master"
4343
topology: "replica_set"
4444
- os: "ubuntu-20.04"
4545
php-version: "8.0"
4646
mongodb-version: "4.4"
47-
driver-version: "stable"
47+
driver-version: "mongodb/mongo-php-driver@master"
4848
topology: "sharded_cluster"
4949

5050
steps:

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"php": "^7.2 || ^8.0",
1313
"ext-hash": "*",
1414
"ext-json": "*",
15-
"ext-mongodb": "^1.12.0",
15+
"ext-mongodb": "^1.13.0",
1616
"jean85/pretty-package-versions": "^1.2 || ^2.0.1",
1717
"symfony/polyfill-php80": "^1.19"
1818
},

tests/UnifiedSpecTests/Context.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use function current;
1818
use function explode;
1919
use function implode;
20-
use function in_array;
2120
use function key;
2221
use function parse_url;
2322
use function PHPUnit\Framework\assertArrayHasKey;
@@ -50,9 +49,6 @@ final class Context
5049
/** @var string */
5150
private $activeClient;
5251

53-
/** @var string[] */
54-
private $dirtySessions = [];
55-
5652
/** @var EntityMap */
5753
private $entityMap;
5854

@@ -134,20 +130,6 @@ public function getInternalClient(): Client
134130
return $this->internalClient;
135131
}
136132

137-
public function isDirtySession(string $sessionId): bool
138-
{
139-
return in_array($sessionId, $this->dirtySessions);
140-
}
141-
142-
public function markDirtySession(string $sessionId): void
143-
{
144-
if ($this->isDirtySession($sessionId)) {
145-
return;
146-
}
147-
148-
$this->dirtySessions[] = $sessionId;
149-
}
150-
151133
public function isActiveClient(string $clientId): bool
152134
{
153135
return $this->activeClient === $clientId;

tests/UnifiedSpecTests/DirtySessionObserver.php

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

tests/UnifiedSpecTests/Operation.php

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -137,11 +137,6 @@ public function assert(bool $rethrowExceptions = false): void
137137
$result = null;
138138
$saveResultAsEntity = null;
139139

140-
if (isset($this->arguments['session'])) {
141-
$dirtySessionObserver = new DirtySessionObserver($this->entityMap->getLogicalSessionId($this->arguments['session']));
142-
$dirtySessionObserver->start();
143-
}
144-
145140
try {
146141
$result = $this->execute();
147142
$saveResultAsEntity = $this->saveResultAsEntity;
@@ -160,14 +155,6 @@ public function assert(bool $rethrowExceptions = false): void
160155
$error = $e;
161156
}
162157

163-
if (isset($dirtySessionObserver)) {
164-
$dirtySessionObserver->stop();
165-
166-
if ($dirtySessionObserver->observedNetworkError()) {
167-
$this->context->markDirtySession($this->arguments['session']);
168-
}
169-
}
170-
171158
if (! $this->ignoreResultAndError) {
172159
$this->expectError->assert($error);
173160
$this->expectResult->assert($result, $saveResultAsEntity);
@@ -744,16 +731,12 @@ private function executeForTestRunner()
744731
Assert::fail('Tests using assertNumberConnectionsCheckedOut should be skipped');
745732
break;
746733
case 'assertSessionDirty':
747-
/* Context::isDirtySession() requires the session ID. Avoid
748-
* checking $args['session'], which is already resolved. */
749-
assertArrayHasKey('session', $this->arguments);
750-
assertTrue($this->context->isDirtySession($this->arguments['session']));
734+
assertArrayHasKey('session', $args);
735+
assertTrue($args['session']->isDirty());
751736
break;
752737
case 'assertSessionNotDirty':
753-
/* Context::isDirtySession() requires the session ID. Avoid
754-
* checking $args['session'], which is already resolved. */
755-
assertArrayHasKey('session', $this->arguments);
756-
assertFalse($this->context->isDirtySession($this->arguments['session']));
738+
assertArrayHasKey('session', $args);
739+
assertFalse($args['session']->isDirty());
757740
break;
758741
case 'assertSessionPinned':
759742
assertArrayHasKey('session', $args);

0 commit comments

Comments
 (0)