function CommandUnishTestCase::parse_backend_output

8.0.x CommandUnishTestCase.php CommandUnishTestCase::parse_backend_output($string)
7.x CommandUnishTestCase.php CommandUnishTestCase::parse_backend_output($string)
master CommandUnishTestCase.php CommandUnishTestCase::parse_backend_output($string)

A slightly less functional copy of drush_backend_parse_output().

14 calls to CommandUnishTestCase::parse_backend_output()
backendCase::testBackendFunctionResult in tests/backendTest.php
Covers the following target responsibilities.
backendCase::testBackendInvokeMultiple in tests/backendTest.php
Covers the following target responsibilities.
backendCase::testBackendMethodGet in tests/backendTest.php
Covers the following target responsibilities.
backendCase::testBackendMethodPost in tests/backendTest.php
Covers the following target responsibilities.
backendCase::testBackendReassembleSplitPackets in tests/backendTest.php
Covers the following target responsibilities.

... See full list

File

tests/Unish/CommandUnishTestCase.php, line 353

Namespace

Unish

Class

CommandUnishTestCase

Code

function parse_backend_output($string) {
  $regex = sprintf(UNISH_BACKEND_OUTPUT_DELIMITER, '(.*)');
  preg_match("/$regex/s", $string, $match);
  if ($match[1]) {
    // we have our JSON encoded string
    $output = $match[1];
    // remove the match we just made and any non printing characters
    $string = trim(str_replace(sprintf(UNISH_BACKEND_OUTPUT_DELIMITER, $match[1]), '', $string));
  }

  if ($output) {
    $data = json_decode($output, TRUE);
    if (is_array($data)) {
      return $data;
    }
  }
  return $string;
}