Skip to content

Commit 29fddd8

Browse files
committed
PHPLIB-688 Report serverless mode in unified test runner
1 parent b0e1080 commit 29fddd8

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@ The `phpunit.xml.dist` file is used as the default configuration file for the
3434
test suite. In addition to various PHPUnit options, it defines required
3535
`MONGODB_URI` and `MONGODB_DATABASE` environment variables. You may customize
3636
this configuration by creating your own `phpunit.xml` file based on the
37-
`phpunit.xml.dist` file we provide.
37+
`phpunit.xml.dist` file we provide. To run the tests in serverless mode, set the
38+
`MONGODB_IS_SERVERLESS` environment variable to `on`.
3839

3940
By default, the `simple-phpunit` binary chooses the correct PHPUnit version for
4041
the PHP version you are running. To run tests against a specific PHPUnit version,

tests/UnifiedSpecTests/UnifiedTestRunner.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919

2020
use function call_user_func;
2121
use function count;
22+
use function filter_var;
2223
use function gc_collect_cycles;
24+
use function getenv;
2325
use function in_array;
2426
use function is_string;
2527
use function PHPUnit\Framework\assertContainsOnly;
@@ -33,6 +35,8 @@
3335
use function strpos;
3436
use function version_compare;
3537

38+
use const FILTER_VALIDATE_BOOLEAN;
39+
3640
/**
3741
* Unified test runner.
3842
*
@@ -339,8 +343,9 @@ private function isAuthenticated(): bool
339343
*/
340344
private function isServerless(): bool
341345
{
342-
// TODO: detect serverless once PHPC-1755 is implemented
343-
return false;
346+
$isServerless = getenv('MONGODB_IS_SERVERLESS');
347+
348+
return $isServerless !== false ? filter_var($isServerless, FILTER_VALIDATE_BOOLEAN) : false;
344349
}
345350

346351
/**

0 commit comments

Comments
 (0)