Skip to content

Commit 017907f

Browse files
authored
Merge pull request #101 from LibreSign/feat/create-sleep-steep
feat: create sleep step
2 parents 1465489 + 14984f9 commit 017907f

3 files changed

Lines changed: 20 additions & 0 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ Given the output of the last command should be empty
6666
Given /^run the command "(?P<command>(?:[^"]|\")*)" with result code (\d+)$/
6767
Given /^run the bash command "(?P<command>(?:[^"]|\")*)" with result code (\d+)$/
6868
Given create an environment :name with value :value to be used by occ command
69+
Given /^wait for ([0-9]+) (second|seconds)$/
70+
Given /^past ([0-9]+) (second|seconds) since wait step$/
6971
```
7072

7173
## Tips

features/test.feature

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,3 +258,7 @@ Feature: Test this extension
258258
"""
259259
I found the environment variable OC_PASS with value 123456
260260
"""
261+
262+
Scenario: Wait for seconds
263+
When wait for 1 seconds
264+
When past 1 second since wait step

src/NextcloudApiContext.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class NextcloudApiContext implements Context {
3232
protected array $fields = [];
3333
protected static array $environments = [];
3434
protected static string $commandOutput = '';
35+
protected int $startWaitFor = 0;
3536

3637
/**
3738
* @var string[]
@@ -544,6 +545,19 @@ public static function createAnEnvironmentWithValueToBeUsedByOccCommand(string $
544545
self::$environments[$name] = $value;
545546
}
546547

548+
#[Given('/^wait for ([0-9]+) (second|seconds)$/')]
549+
public function waitForXSecond(int $seconds): void {
550+
$this->startWaitFor = $seconds;
551+
sleep($seconds);
552+
}
553+
554+
#[Given('/^past ([0-9]+) (second|seconds) since wait step$/')]
555+
public function pastXSecondsSinceWaitStep(int $seconds): void {
556+
$currentTime = time();
557+
$startTime = $currentTime - $this->startWaitFor;
558+
Assert::assertGreaterThanOrEqual($startTime, $currentTime, 'The current time is not greater than or equal to the start time.');
559+
}
560+
547561
#[AfterScenario()]
548562
public function tearDown(): void {
549563
self::$environments = [];

0 commit comments

Comments
 (0)