Skip to content

Commit 573676c

Browse files
committed
test: call PhpStreamWrapper::restore() as soon as possible
If it is not called, assertions may not work correctly.
1 parent 6cb01b1 commit 573676c

1 file changed

Lines changed: 6 additions & 7 deletions

File tree

tests/system/CLI/CLITest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,9 @@ public function testWaitZero(): void
7676
$time = time();
7777
CLI::wait(0);
7878

79-
$this->assertCloseEnough(0, time() - $time);
80-
8179
PhpStreamWrapper::restore();
80+
81+
$this->assertCloseEnough(0, time() - $time);
8282
}
8383

8484
public function testPrompt(): void
@@ -90,9 +90,9 @@ public function testPrompt(): void
9090

9191
$output = CLI::prompt('What is your favorite color?');
9292

93-
$this->assertSame($expected, $output);
94-
9593
PhpStreamWrapper::restore();
94+
95+
$this->assertSame($expected, $output);
9696
}
9797

9898
public function testPromptByMultipleKeys(): void
@@ -105,14 +105,13 @@ public function testPromptByMultipleKeys(): void
105105
$options = ['Playing game', 'Sleep', 'Badminton'];
106106
$output = CLI::promptByMultipleKeys('Select your hobbies:', $options);
107107

108+
PhpStreamWrapper::restore();
109+
108110
$expected = [
109111
0 => 'Playing game',
110112
1 => 'Sleep',
111113
];
112-
113114
$this->assertSame($expected, $output);
114-
115-
PhpStreamWrapper::restore();
116115
}
117116

118117
public function testNewLine(): void

0 commit comments

Comments
 (0)