function backendCase::testBackendReassembleSplitPackets

8.0.x backendTest.php backendCase::testBackendReassembleSplitPackets()
6.x backendTest.php backendCase::testBackendReassembleSplitPackets()
7.x backendTest.php backendCase::testBackendReassembleSplitPackets()
5.x backendTest.php backendCase::testBackendReassembleSplitPackets()
master backendTest.php backendCase::testBackendReassembleSplitPackets()

Covers the following target responsibilities.

  • Insures that backend invoke can properly re-assemble packets that are split across process-read-size boundaries.

This test works by repeating testBackendMethodGet(), while setting '#process-read-size' to a very small value, insuring that packets will be split.

File

tests/backendTest.php, line 224
We choose to test the backend system in two parts. - Origin. These tests assure that we are generate a proper ssh command when a backend invoke is needed. - Target. These tests assure that drush generates a delimited JSON array …

Class

backendCase

Code

function testBackendReassembleSplitPackets() {
  $options = array(
    'backend' => NULL,
    'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
  );
  $min = 1;
  $max = 4;
  $read_sizes_to_test = array(4096);
  if (in_array('--debug', $_SERVER['argv'])) {
    $read_sizes_to_test[] = 128;
    $read_sizes_to_test[] = 16;
    $max = 16;
  }
  foreach ($read_sizes_to_test as $read_size) {
    $log_message = "";
    for ($i = $min; $i <= $max; $i++) {
      $log_message .= "X";
      $php = "\$values = drush_invoke_process('@none', 'unit-return-options', array('value'), array('log-message' => '$log_message', 'x' => 'y$read_size', 'strict' => 0, 'data' => array('a' => 1, 'b' => 2)), array('method' => 'GET', '#process-read-size' => $read_size)); return array_key_exists('object', \$values) ? \$values['object'] : 'no result';";
      $this->drush('php-eval', array($php), $options);
      $parsed = parse_backend_output($this->getOutput());
      // assert that $parsed has 'x' but not 'data'
      $all_warnings = array();
      foreach ($parsed['log'] as $log) {
        if ($log['type'] == 'warning') {
          $all_warnings[] = $log['message'];
        }
      }
      $this->assertEquals("$log_message,done", implode(',', $all_warnings), 'Log reconstruction with read_size ' . $read_size);
      $this->assertEquals("array (
  'x' => 'y$read_size',
)", var_export($parsed['object'], TRUE));
    }
  }
}