~ubuntu-branches/ubuntu/vivid/phabricator/vivid-proposed

« back to all changes in this revision

Viewing changes to libphutil/src/phage/__tests__/PhageAgentTestCase.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-10-23 20:49:26 UTC
  • mfrom: (0.2.1) (0.1.1)
  • Revision ID: package-import@ubuntu.com-20141023204926-vq80u1op4df44azb
Tags: 0~git20141023-1
Initial release (closes: #703046)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class PhageAgentTestCase extends PhutilTestCase {
 
4
 
 
5
  public function testPhagePHPAgent() {
 
6
    return $this->runBootloaderTests(new PhagePHPAgentBootloader());
 
7
  }
 
8
 
 
9
  private function runBootloaderTests(PhageAgentBootloader $boot) {
 
10
    $name = get_class($boot);
 
11
 
 
12
    $exec = new ExecFuture('%C', $boot->getBootCommand());
 
13
    $exec->write($boot->getBootSequence(), $keep_open = true);
 
14
 
 
15
    $exec_channel = new PhutilExecChannel($exec);
 
16
    $agent = new PhutilJSONProtocolChannel($exec_channel);
 
17
 
 
18
    $agent->write(
 
19
      array(
 
20
        'type'    => 'EXEC',
 
21
        'key'     => 1,
 
22
        'command' => 'echo phage',
 
23
      ));
 
24
 
 
25
    $this->agentExpect(
 
26
      $agent,
 
27
      array(
 
28
        'type'    => 'RSLV',
 
29
        'key'     => 1,
 
30
        'err'     => 0,
 
31
        'stdout'  => "phage\n",
 
32
        'stderr'  => '',
 
33
      ),
 
34
      "'echo phage' for {$name}");
 
35
 
 
36
    $agent->write(
 
37
      array(
 
38
        'type'    => 'EXIT',
 
39
      ));
 
40
  }
 
41
 
 
42
  private function agentExpect(PhutilChannel $agent, $expect, $what) {
 
43
    $message = $agent->waitForMessage();
 
44
    $this->assertEqual($expect, $message, $what);
 
45
  }
 
46
 
 
47
}