Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ Given the output of the last command should be empty
Given /^run the command "(?P<command>(?:[^"]|\\")*)" with result code (\d+)$/
Given /^run the bash command "(?P<command>(?:[^"]|\\")*)" with result code (\d+)$/
Given create an environment :name with value :value to be used by occ command
Given /^wait for ([0-9]+) (second|seconds)$/
Given /^past ([0-9]+) (second|seconds) since wait step$/
```

## Tips
Expand Down
4 changes: 4 additions & 0 deletions features/test.feature
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,7 @@ Feature: Test this extension
"""
I found the environment variable OC_PASS with value 123456
"""

Scenario: Wait for seconds
When wait for 1 seconds
When past 1 second since wait step
14 changes: 14 additions & 0 deletions src/NextcloudApiContext.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ class NextcloudApiContext implements Context {
protected array $fields = [];
protected static array $environments = [];
protected static string $commandOutput = '';
protected int $startWaitFor = 0;

/**
* @var string[]
Expand Down Expand Up @@ -544,6 +545,19 @@ public static function createAnEnvironmentWithValueToBeUsedByOccCommand(string $
self::$environments[$name] = $value;
}

#[Given('/^wait for ([0-9]+) (second|seconds)$/')]
public function waitForXSecond(int $seconds): void {
$this->startWaitFor = $seconds;
sleep($seconds);
}

#[Given('/^past ([0-9]+) (second|seconds) since wait step$/')]
public function pastXSecondsSinceWaitStep(int $seconds): void {
$currentTime = time();
$startTime = $currentTime - $this->startWaitFor;
Assert::assertGreaterThanOrEqual($startTime, $currentTime, 'The current time is not greater than or equal to the start time.');
}

#[AfterScenario()]
public function tearDown(): void {
self::$environments = [];
Expand Down
Loading