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

Class

backendCase

Code

function testBackendReassembleSplitPackets() {
  $options = array(
    'backend' => NULL,
    'include' => dirname(__FILE__), // Find unit.drush.inc commandfile.
  );
  $read_sizes_to_test = array(4096, 128, 16);
  foreach ($read_sizes_to_test as $read_size) {
    $log_message = "";
    for ($i = 1; $i <= 16; $i++) {
      $log_message .= "X";
      $php = "\$values = drush_invoke_process('@none', 'unit-return-options', array('value'), array('log-message' => '$log_message', 'x' => 'y$read_size', '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));
    }
  }
}