mirror of
https://codeberg.org/icewind/SMB.git
synced 2026-06-04 01:34:07 +02:00
Split out and improve tests
This commit is contained in:
parent
5c57d2d094
commit
65b76d6428
3 changed files with 74 additions and 95 deletions
|
|
@ -38,23 +38,14 @@ class Connection extends RawConnection {
|
|||
|
||||
$output = array();
|
||||
$line = $this->readLine();
|
||||
$length = strlen(self::DELIMITER);
|
||||
while (substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter
|
||||
$length = mb_strlen(self::DELIMITER);
|
||||
while (mb_substr($line, 0, $length) !== self::DELIMITER) { //next prompt functions as delimiter
|
||||
$output[] .= $line;
|
||||
$line = parent::read();
|
||||
$line = $this->readLine();
|
||||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* read a single line of unprocessed output
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function readLine() {
|
||||
return parent::read();
|
||||
}
|
||||
|
||||
/**
|
||||
* check if the first line holds a connection failure
|
||||
*
|
||||
|
|
|
|||
|
|
@ -35,7 +35,8 @@ class RawConnection {
|
|||
setlocale(LC_ALL, Server::LOCALE);
|
||||
$env = array_merge($env, array(
|
||||
'CLI_FORCE_INTERACTIVE' => 'y', // Needed or the prompt isn't displayed!!
|
||||
'LC_ALL' => Server::LOCALE
|
||||
'LC_ALL' => Server::LOCALE,
|
||||
'LANG' => Server::LOCALE
|
||||
));
|
||||
$this->process = proc_open($command, $descriptorSpec, $this->pipes, '/', $env);
|
||||
if (!$this->isValid()) {
|
||||
|
|
@ -72,8 +73,8 @@ class RawConnection {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
public function read() {
|
||||
return trim(fgets($this->getOutputStream()));
|
||||
public function readLine() {
|
||||
return stream_get_line($this->getOutputStream(), 4086, "\n");
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -83,7 +84,7 @@ class RawConnection {
|
|||
*/
|
||||
public function readAll() {
|
||||
$output = array();
|
||||
while ($line = $this->read()) {
|
||||
while ($line = $this->readLine()) {
|
||||
$output[] = $line;
|
||||
}
|
||||
return $output;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue