Skip to content

Commit 8f7dad4

Browse files
committed
Split transactions tests for more targeted execution
The tests for transactions are the same for the classic and convenient APIs. Since the serverless spec excludes the convenient API from testing, we need to split this so we can only target the classic API for testing.
1 parent 60bd25a commit 8f7dad4

File tree

1 file changed

+29
-4
lines changed

1 file changed

+29
-4
lines changed

tests/SpecTests/TransactionsSpecTest.php

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,17 +110,42 @@ public static function assertCommandMatches(stdClass $expected, stdClass $actual
110110
static::assertDocumentsMatch($expected, $actual);
111111
}
112112

113+
/**
114+
* @dataProvider provideTransactionsTests
115+
*/
116+
public function testTransactions(stdClass $test, ?array $runOn = null, array $data, ?string $databaseName = null, ?string $collectionName = null): void
117+
{
118+
$this->runTransactionTest($test, $runOn, $data, $databaseName, $collectionName);
119+
}
120+
121+
public function provideTransactionsTests(): array
122+
{
123+
return $this->provideTests('transactions');
124+
}
125+
126+
/**
127+
* @dataProvider provideTransactionsConvenientApiTests
128+
*/
129+
public function testTransactionsConvenientApi(stdClass $test, ?array $runOn = null, array $data, ?string $databaseName = null, ?string $collectionName = null): void
130+
{
131+
$this->runTransactionTest($test, $runOn, $data, $databaseName, $collectionName);
132+
}
133+
134+
public function provideTransactionsConvenientApiTests(): array
135+
{
136+
return $this->provideTests('transactions-convenient-api');
137+
}
138+
113139
/**
114140
* Execute an individual test case from the specification.
115141
*
116-
* @dataProvider provideTests
117142
* @param stdClass $test Individual "tests[]" document
118143
* @param array $runOn Top-level "runOn" array with server requirements
119144
* @param array $data Top-level "data" array to initialize collection
120145
* @param string $databaseName Name of database under test
121146
* @param string $collectionName Name of collection under test
122147
*/
123-
public function testTransactions(stdClass $test, ?array $runOn = null, array $data, ?string $databaseName = null, ?string $collectionName = null): void
148+
private function runTransactionTest(stdClass $test, ?array $runOn = null, array $data, ?string $databaseName = null, ?string $collectionName = null): void
124149
{
125150
if (isset(self::$incompleteTests[$this->dataDescription()])) {
126151
$this->markTestIncomplete(self::$incompleteTests[$this->dataDescription()]);
@@ -173,11 +198,11 @@ public function testTransactions(stdClass $test, ?array $runOn = null, array $da
173198
}
174199
}
175200

176-
public function provideTests()
201+
private function provideTests(string $dir): array
177202
{
178203
$testArgs = [];
179204

180-
foreach (glob(__DIR__ . '/transactions*/*.json') as $filename) {
205+
foreach (glob(__DIR__ . '/' . $dir . '/*.json') as $filename) {
181206
$json = $this->decodeJson(file_get_contents($filename));
182207
$group = basename(dirname($filename)) . '/' . basename($filename, '.json');
183208
$runOn = $json->runOn ?? null;

0 commit comments

Comments
 (0)