Skip to content
Merged
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
17 changes: 17 additions & 0 deletions src/NextcloudApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
use Behat\Behat\Context\Context;
use Behat\Gherkin\Node\PyStringNode;
use Behat\Gherkin\Node\TableNode;
use Behat\Testwork\Hook\Scope\BeforeSuiteScope;
use DOMDocument;
use Exception;
use GuzzleHttp\Client;
use GuzzleHttp\Cookie\CookieJar;
use GuzzleHttp\Exception\ClientException;
Expand Down Expand Up @@ -46,6 +48,21 @@ public function __construct(?array $parameters = []) {
}
}

/**
* @BeforeSuite
*/
public static function beforeSuite(BeforeSuiteScope $scope):void {
$whoami = (string) exec('whoami');
if (get_current_user() !== $whoami) {
$command = implode(' ', $_SERVER['argv'] ?? []);
throw new Exception(sprintf(
"Have files that %s is the owner and the user that is running this test is %s, is necessary to be the same user.\n" .
"You should run the follow command:\n" .
"runuser -u %s -- %s\n\n",
get_current_user(), $whoami, get_current_user(), $command));
}
}

/**
* @BeforeScenario
*/
Expand Down