test(behat): reset per-scenario state in BasicStructure and Sharing

Add @BeforeScenario hooks to reset auth/server state and sharing state
between scenarios, preventing state bleed across test runs.

- BasicStructure: reset currentUser, currentServer, baseUrl, apiVersion,
  requestToken and cookieJar (baseUrl and currentServer go together via
  usingServer(), so both must be reset)
- Sharing: reset lastShareData, storedShareData and savedShareId

Signed-off-by: Anna Larch <anna@nextcloud.com>
AI-Assisted-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Anna Larch 2026-05-27 16:06:54 +02:00
parent 5ffde0370b
commit d58e55ad63
2 changed files with 21 additions and 0 deletions

View file

@ -72,6 +72,18 @@ trait BasicStructure {
}
}
/**
* @BeforeScenario
*/
public function resetAuthState(): void {
$this->currentUser = '';
$this->currentServer = 'LOCAL';
$this->baseUrl = $this->localBaseUrl;
$this->apiVersion = 1;
$this->requestToken = null;
$this->cookieJar = new CookieJar();
}
/**
* @Given /^using api version "(\d+)"$/
*/

View file

@ -23,6 +23,15 @@ trait Sharing {
/** @var SimpleXMLElement[] */
private array $storedShareData = [];
private ?string $savedShareId = null;
/**
* @BeforeScenario
*/
public function resetSharingState(): void {
$this->lastShareData = null;
$this->storedShareData = [];
$this->savedShareId = null;
}
/** @var ResponseInterface */
private $response;