~ubuntu-branches/ubuntu/wily/phabricator/wily

« back to all changes in this revision

Viewing changes to src/configuration/__tests__/ArcanistBritishTestCase.php

  • Committer: Package Import Robot
  • Author(s): Richard Sellam
  • Date: 2014-11-01 23:20:06 UTC
  • mto: This revision was merged to the branch mainline in revision 4.
  • Revision ID: package-import@ubuntu.com-20141101232006-mvlnp0cil67tsboe
Tags: upstream-0~git20141101/arcanist
Import upstream version 0~git20141101, component arcanist

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
 
 
3
final class ArcanistBritishTestCase extends ArcanistTestCase {
 
4
 
 
5
  public function testCommandCompletion() {
 
6
    $this->assertCommandCompletion(
 
7
      array('land'),
 
8
      'alnd',
 
9
      array('land', 'amend'));
 
10
 
 
11
    $this->assertCommandCompletion(
 
12
      array('branch'),
 
13
      'brnach',
 
14
      array('branch', 'browse'));
 
15
 
 
16
    $this->assertCommandCompletion(
 
17
      array(),
 
18
      'test',
 
19
      array('list', 'unit'));
 
20
 
 
21
    $this->assertCommandCompletion(
 
22
      array('list'),
 
23
      'lists',
 
24
      array('list'));
 
25
 
 
26
    $this->assertCommandCompletion(
 
27
      array('diff'),
 
28
      'dfif',
 
29
      array('diff'));
 
30
 
 
31
    $this->assertCommandCompletion(
 
32
      array('unit'),
 
33
      'uint',
 
34
      array('unit', 'lint', 'list'));
 
35
 
 
36
    $this->assertCommandCompletion(
 
37
      array('list', 'lint'),
 
38
      'nilt',
 
39
      array('unit', 'lint', 'list'));
 
40
  }
 
41
 
 
42
  private function assertCommandCompletion($expect, $input, $commands) {
 
43
    $result = ArcanistConfiguration::correctCommandSpelling(
 
44
      $input,
 
45
      $commands,
 
46
      2);
 
47
 
 
48
    sort($result);
 
49
    sort($expect);
 
50
 
 
51
    $commands = implode(', ', $commands);
 
52
 
 
53
    $this->assertEqual(
 
54
      $expect,
 
55
      $result,
 
56
      "Correction of {$input} against: {$commands}");
 
57
  }
 
58
 
 
59
  public function testArgumentCompletion() {
 
60
    $this->assertArgumentCompletion(
 
61
      array('nolint'),
 
62
      'no-lint',
 
63
      array('nolint', 'nounit'));
 
64
 
 
65
    $this->assertArgumentCompletion(
 
66
      array('reviewers'),
 
67
      'reviewer',
 
68
      array('reviewers', 'cc'));
 
69
 
 
70
    $this->assertArgumentCompletion(
 
71
      array(),
 
72
      'onlint',
 
73
      array('nolint'));
 
74
 
 
75
    $this->assertArgumentCompletion(
 
76
      array(),
 
77
      'nolind',
 
78
      array('nolint'));
 
79
  }
 
80
 
 
81
  private function assertArgumentCompletion($expect, $input, $arguments) {
 
82
    $result = ArcanistConfiguration::correctArgumentSpelling(
 
83
      $input,
 
84
      $arguments);
 
85
 
 
86
    sort($result);
 
87
    sort($expect);
 
88
 
 
89
    $arguments = implode(', ', $arguments);
 
90
 
 
91
    $this->assertEqual(
 
92
      $expect,
 
93
      $result,
 
94
      "Correction of {$input} against: {$arguments}");
 
95
  }
 
96
 
 
97
}