Skip to content

Commit 14984f9

Browse files
committed
feat: improve test
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 243ec3c commit 14984f9

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ 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
6969
Given /^wait for ([0-9]+) (second|seconds)$/
70+
Given /^past ([0-9]+) (second|seconds) since wait step$/
7071
```
7172

7273
## Tips

features/test.feature

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,3 +261,4 @@ Feature: Test this extension
261261

262262
Scenario: Wait for seconds
263263
When wait for 1 seconds
264+
When past 1 second since wait step

src/NextcloudApiContext.php

Lines changed: 9 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[]
@@ -546,9 +547,17 @@ public static function createAnEnvironmentWithValueToBeUsedByOccCommand(string $
546547

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

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+
552561
#[AfterScenario()]
553562
public function tearDown(): void {
554563
self::$environments = [];

0 commit comments

Comments
 (0)