From 4ec4f869631031d2a289af7a9aa68ac9a00590aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Wed, 24 Jul 2024 13:35:24 +0200 Subject: [PATCH] tests: Add environment variable and document commands to run behat tests locally MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- README.md | 6 ++++++ tests/integration/features/bootstrap/ServerContext.php | 8 +++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 99ac92bae..5be857280 100644 --- a/README.md +++ b/README.md @@ -105,6 +105,12 @@ You can use the provided Makefile to run all tests by using: make test +#### Running behat integration tests + +Within `tests/integration/` run `composer install` and then choose one of the two options: +- Run tests with a local php server: `bash run.sh` +- Run against an existing Nextcloud installation: `BEHAT_SERVER_URL=http://nextcloud.local ./vendor/bin/behat --colors features/decks.feature` + ### Documentation The documentation for our REST API can be found at https://deck.readthedocs.io/en/latest/API/ diff --git a/tests/integration/features/bootstrap/ServerContext.php b/tests/integration/features/bootstrap/ServerContext.php index cdc8f1984..5e3872720 100644 --- a/tests/integration/features/bootstrap/ServerContext.php +++ b/tests/integration/features/bootstrap/ServerContext.php @@ -16,7 +16,13 @@ class ServerContext implements Context { public function __construct($baseUrl) { $this->rawBaseUrl = $baseUrl; - $this->__tConstruct($baseUrl . '/index.php/ocs/', ['admin', 'admin'], '123456'); + + $testServerUrl = getenv('BEHAT_SERVER_URL'); + if ($testServerUrl !== false) { + $this->rawBaseUrl = rtrim($testServerUrl, '/'); + } + + $this->__tConstruct($this->rawBaseUrl . '/ocs/', ['admin', 'admin'], '123456'); }