Skip to content

Conversation

yondifon
Copy link

Add missing waitUntil method to FakeInvokedProcess

Problem

The FakeInvokedProcess class was missing the waitUntil method that exists in InvokedProcess, causing test failures when using faked processes.

Solution

Added waitUntil method to both the contract interface and FakeInvokedProcess implementation with comprehensive tests.

Example

Before: This would fail with faked processes

//test 
Process::fake([
    'long-process *' => Process::describe()
          ->output('booting')
          ->output('ready')
          ->iterations(2),
]);

// code
$process = Process::start('long-process');
$result = $process->waitUntil(fn($type, $buffer) => str_contains($buffer, 'ready'));

After: Now works perfectly
// Same code now works with faked processes
$this->assertTrue($result->successful());

Benefits

  • Consistent behavior between real and faked processes
  • Enables proper testing of asynchronous process workflows
  • Fully backward compatible

Comment on lines +64 to +71

/**
* Wait until the given callback returns true.
*
* @param callable|null $output
* @return \Illuminate\Process\ProcessResult
*/
public function waitUntil(?callable $output = null);
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be removed from here. this wasn't included here for a reason i guess.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What can be removed from where?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We didn’t have ‎waitUntil in the contract before but implemented in the real class. If there’s a specific reason it was left out, we can just remove it.

@taylorotwell taylorotwell marked this pull request as draft September 12, 2025 14:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants