Skip to content

Commit c1fe481

Browse files
[12.x] Add test coverage for Process sequence with multiple env variables (#55406)
* Add test for Filesystem lastModified method * add process sequence test with multiple environment variables * fix style
1 parent 109a967 commit c1fe481

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

tests/Process/ProcessTest.php

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,37 @@ public function testAssertingThatNothingRan()
795795
$factory->assertNothingRan();
796796
}
797797

798+
public function testProcessWithMultipleEnvironmentVariablesAndSequences()
799+
{
800+
$factory = new Factory;
801+
802+
$factory->fake([
803+
'printenv TEST_VAR OTHER_VAR' => $factory->sequence()
804+
->push("test_value\nother_value")
805+
->push("new_test_value\nnew_other_value"),
806+
]);
807+
808+
$result = $factory->env([
809+
'TEST_VAR' => 'test_value',
810+
'OTHER_VAR' => 'other_value',
811+
])->run('printenv TEST_VAR OTHER_VAR');
812+
813+
$this->assertTrue($result->successful());
814+
$this->assertEquals("test_value\nother_value\n", $result->output());
815+
816+
$result = $factory->env([
817+
'TEST_VAR' => 'new_test_value',
818+
'OTHER_VAR' => 'new_other_value',
819+
])->run('printenv TEST_VAR OTHER_VAR');
820+
821+
$this->assertTrue($result->successful());
822+
$this->assertEquals("new_test_value\nnew_other_value\n", $result->output());
823+
824+
$factory->assertRanTimes(function ($process) {
825+
return str_contains($process->command, 'printenv TEST_VAR OTHER_VAR');
826+
}, 2);
827+
}
828+
798829
protected function ls()
799830
{
800831
return windows_os() ? 'dir' : 'ls';

0 commit comments

Comments
 (0)