private function waitForExpectedResponse($expectation, $timeout)
    {
        $response           = null;
        $lastLoggedResponse = null;
        $buffer             = '';
        $start              = time();
        stream_set_blocking($this->pipes[1], false);

        while (true) {
            if (time() - $start >= $timeout) {
                throw new ProcessTimeoutException();
            }

            if (feof($this->pipes[1])) {
                throw new UnexpectedEOFException();
            }

            if (!$this->isRunning()) {
                throw new ProcessTerminatedException();
            }

            $buffer .= fread($this->pipes[1], 4096);
            $response = static::trimAnswer($buffer);

            if ($response !== '' && $response !== $lastLoggedResponse) {
                $lastLoggedResponse = $response;
                $this->logger->info("Expected '{$expectation}', got '{$response}'");
            }

            if (fnmatch($expectation, $response)) {
                return;
            }
        }
    }
private function waitForExpectedResponse($expectation, $timeout)
    {
        $response           = null;
        $lastLoggedResponse = null;
        $buffer             = '';
        $start              = time();
        stream_set_blocking($this->pipes[1], false);

        while (true) {
            if (time() - $start >= $timeout) {
                throw new ProcessTimeoutException();
            }

            if (feof($this->pipes[1])) {
                throw new UnexpectedEOFException();
            }

            if (!$this->isRunning()) {
                throw new ProcessTerminatedException();
            }

            $buffer .= fread($this->pipes[1], 4096);
            $response = static::trimAnswer($buffer);

            if ($response !== '' && $response !== $lastLoggedResponse) {
                $lastLoggedResponse = $response;
                $this->logger->info("Expected '{$expectation}', got '{$response}'");
            }

            if (fnmatch($expectation, $response)) {
                return;
            }
        }
    }
private function waitForExpectedResponse ( $ expectation , $ timeout ) { $ response = null ; $ lastLoggedResponse = null ; $ buffer = '' ; $ start = time ( ) ; stream_set_blocking ( $ this -> pipes [ 1 ] , false ) ; while ( true ) { if ( time ( ) - $ start >= $ timeout ) { throw new ProcessTimeoutException ( ) ; } if ( feof ( $ this -> pipes [ 1 ] ) ) { throw new UnexpectedEOFException ( ) ; } if ( ! $ this -> isRunning ( ) ) { throw new ProcessTerminatedException ( ) ; } $ buffer .= fread ( $ this -> pipes [ 1 ] , 4096 ) ; $ response = static :: trimAnswer ( $ buffer ) ; if ( $ response !== '' && $ response !== $ lastLoggedResponse ) { $ lastLoggedResponse = $ response ; $ this -> logger -> info ( "Expected '{$expectation}', got '{$response}'" ) ; } if ( fnmatch ( $ expectation , $ response ) ) { return ; } } }
Wait for the given response to show on stdout.

@param  string $expectation The expected output.  Will be glob matched.
@return null
@throws \Yuloh\Expect\Exceptions\ProcessTimeoutException if the process times out.
@throws \Yuloh\Expect\Exceptions\UnexpectedEOFException if an unexpected EOF is found.
@throws \Yuloh\Expect\Exceptions\ProcessTerminatedException if the process is terminated
before the expectation is met.
Wait for the given response to show on stdout .