Skip to content
This repository
Browse code

Moved CLI component and delegated to use Silly.

  • Loading branch information...
commit 420adb1fc73afc7e7753c9b8e63102038620f102 1 parent 7bc5402
authored
74  README.md
Source Rendered
@@ -19,50 +19,58 @@ Hypothetical Example
19 19
 
20 20
 Dependency information is stored in a mytroupe file (here we use mytroupe.php)
21 21
 
22  
-    // mytroupe.php
23  
-    return array(
24  
-      'symfony' => array(
25  
-        'url'     => 'git://github.com/symfony/symfony.git',
26  
-        'alias'   => 'symfony2', // This will be the directory name the source will be renamed to. Defaults to label/name
27  
-        'move_to' => 'lib/src', // Defaults to 'vendor_dir' in settings
28  
-      ),
29  
-
30  
-      'doctrine' => 'git://github.com/doctrine/doctrine2.git',
31  
-
32  
-      // Pear import is not yet implemented
33  
-      'phpunit' => array(
34  
-        'type' => 'pear',
35  
-        'channel' => 'pear.phpunit.de',
36  
-        'pear_name' => 'phpunit/PHPUnit'
37  
-      ),
38  
-      // Or 'phpunit' => 'pear://pear.phpunit.de/PHPUnit'
39  
-
40  
-      'minify' => 'http://code.google.com/p/minify/downloads/detail?name=minify_2.1.3.zip',
41  
-
42  
-      // This checks the platform or environment where the application runs
43  
-      '_platform' => array(
44  
-        'php_version' => '5.3.x'
45  
-      ),
46  
-
47  
-      // This is for the project settings
48  
-      '_settings' => array(
49  
-        'vendor_dir' => 'lib/src', // Default is 'vendor'
50  
-      ),
51  
-    );
  22
+```php
  23
+// mytroupe.php
  24
+return array(
  25
+  'symfony' => array(
  26
+    'url'     => 'git://github.com/symfony/symfony.git',
  27
+    'alias'   => 'symfony2', // This will be the directory name the source will be renamed to. Defaults to label/name
  28
+    'move_to' => 'lib/src', // Defaults to 'vendor_dir' in settings
  29
+  ),
  30
+
  31
+  'doctrine' => 'git://github.com/doctrine/doctrine2.git',
  32
+
  33
+  // Pear import is not yet implemented
  34
+  'phpunit' => array(
  35
+    'type' => 'pear',
  36
+    'channel' => 'pear.phpunit.de',
  37
+    'pear_name' => 'phpunit/PHPUnit'
  38
+  ),
  39
+  // Or 'phpunit' => 'pear://pear.phpunit.de/PHPUnit'
  40
+
  41
+  'minify' => 'http://code.google.com/p/minify/downloads/detail?name=minify_2.1.3.zip',
  42
+
  43
+  // This checks the platform or environment where the application runs
  44
+  '_platform' => array(
  45
+    'php_version' => '5.3.x'
  46
+  ),
  47
+
  48
+  // This is for the project settings
  49
+  '_this' => array(
  50
+    'vendor_dir' => 'lib/src', // Default is 'vendor'
  51
+  ),
  52
+);
  53
+```
52 54
 
53 55
 Then one can run this in terminal:
54 56
 
55  
-    troupe assemble
  57
+```bash
  58
+$ troupe assemble
  59
+```
56 60
 
57 61
 And voila! Dependencies solved.
58 62
 
59 63
 To update your sources, execute:
60 64
 
61  
-    troupe update
  65
+```bash
  66
+$ troupe update
  67
+```
62 68
 
63 69
 To list all dependencies:
64 70
 
65  
-    troupe list
  71
+```bash
  72
+$ troupe list
  73
+```
66 74
 
67 75
 
68 76
 Requirements
3  bin/troupe
@@ -8,7 +8,8 @@ $classLoader->register();
8 8
 $classLoader = new SplClassLoader('Pimple', $path . '/Pimple/lib');
9 9
 $classLoader->register();
10 10
 require_once 'Cibo/Cibo.php';
  11
+require_once 'Silly/Silly.php';
11 12
 $container = new \Troupe\Container(getcwd(), $argv);
12  
-$container->EnvironmentHelper->run();
  13
+$container['EnvironmentHelper']->run();
13 14
 ?>
14 15
 
4  notes/TODO.txt
... ...
@@ -1,2 +1,4 @@
1 1
 NEXT:
2  
-- Create a test case for setting _settings
  2
+- Create a test case for setting _this
  3
+- Move Pimple inside Troupe Source
  4
+- Proper encapsulation ... stop revealing Pimple's guts to the whole world.
49  src/Troupe/Cli/Command.php
... ...
@@ -1,49 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-
5  
-class Command {
6  
-
7  
-  private
8  
-    $caller,
9  
-    $namespace,
10  
-    $command,
11  
-    $flags = array(),
12  
-    $arguments = array();
13  
-
14  
-  function __construct(array $options) {
15  
-    foreach(
16  
-      array('caller', 'command', 'namespace', 'flags', 'arguments')
17  
-      as $name
18  
-    ) {
19  
-      $this->setIfExists($name, $options);
20  
-    }
21  
-  }
22  
-
23  
-  private function setIfExists($name, $array) {
24  
-    if (array_key_exists($name, $array)) {
25  
-      $this->$name = $array[$name];
26  
-    }
27  
-  }
28  
-
29  
-  function getCaller() {
30  
-    return $this->caller;
31  
-  }
32  
-
33  
-  function getNamespace() {
34  
-    return $this->namespace;
35  
-  }
36  
-
37  
-  function getCommand() {
38  
-    return $this->command;
39  
-  }
40  
-
41  
-  function getFlags() {
42  
-    return $this->flags;
43  
-  }
44  
-
45  
-  function getArguments() {
46  
-    return $this->arguments;
47  
-  }
48  
-
49  
-}
36  src/Troupe/Cli/Controller.php
... ...
@@ -1,36 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-
5  
-class Controller {
6  
-  
7  
-  private $interpreter, $executor, $cwd, $out_first;
8  
-  
9  
-  function __construct(Interpreter $interpreter, Executor $executor, $cwd) {
10  
-    $this->interpreter = $interpreter;
11  
-    $this->executor = $executor;
12  
-    $this->cwd = $cwd;
13  
-  }
14  
-  
15  
-  function execute(array $arguments) {
16  
-    $this->executor->execute($this->interpreter->interpret($arguments));
17  
-  }
18  
-  
19  
-  function register(Tasks $tasklist) {
20  
-    $this->executor->registerTasks($tasklist, $tasklist->getTaskNamespace());
21  
-    $tasklist->setController($this);
22  
-  }
23  
-  
24  
-  function getRegisteredTasks() {
25  
-    return $this->executor->getRegisteredTasks();
26  
-  }
27  
-  
28  
-  function out($string) {
29  
-      echo $string,"\n";
30  
-  }
31  
-  
32  
-  function getWorkingDirectory() {
33  
-    return $this->cwd;
34  
-  }
35  
-  
36  
-}
5  src/Troupe/Cli/Exception.php
... ...
@@ -1,5 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-
5  
-class Exception extends \Troupe\Exception {}
5  src/Troupe/Cli/Exception/UndefinedTask.php
... ...
@@ -1,5 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli\Exception;
4  
-
5  
-class UndefinedTask extends \Troupe\Cli\Exception {}
96  src/Troupe/Cli/Executor.php
... ...
@@ -1,96 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-
5  
-use \Troupe\Cli\Command;
6  
-use \Troupe\Utilities;
7  
-use \Troupe\Cli\Exception\UndefinedTask as ExceptionUndefinedTask;
8  
-
9  
-class Executor {
10  
-
11  
-  private
12  
-    $utilities,
13  
-    $tasklists_n = array(),
14  
-    $tasklists = array();
15  
-
16  
-  function __construct(Utilities $utilities) {
17  
-    $this->utilities = $utilities;
18  
-  }
19  
-  
20  
-  function registerTasks(Tasks $tasks, $namespace = null) {
21  
-    if ($namespace) {
22  
-      $this->tasklists_n[$namespace] = $tasks;
23  
-    } else {
24  
-      $this->tasklists[] = $tasks;
25  
-    }
26  
-  }
27  
-  
28  
-  function execute(Command $command) {
29  
-    $method = 'task' . $this->utilities->camelCase($command->getCommand());
30  
-    $method_called = false;
31  
-    if (array_key_exists($command->getNamespace(), $this->tasklists_n)) {
32  
-      $method_called = $this->invokeTaskMethod(
33  
-        $this->tasklists_n[$command->getNamespace()], $method,
34  
-        $command->getArguments()
35  
-      );
36  
-    } else {
37  
-      $tasklistsr = array_reverse($this->tasklists, true);
38  
-      foreach ($tasklistsr as $tasklist) {
39  
-        $method_called = $this->invokeTaskMethod(
40  
-          $tasklist, $method, $command->getArguments()
41  
-        );
42  
-        if ($method_called) break;
43  
-      }
44  
-    }
45  
-    if ($command->getCommand() && !$method_called) {
46  
-      throw new ExceptionUndefinedTask(
47  
-        "The task method '$method' is not defined."
48  
-      );
49  
-    }
50  
-    if ($command->getFlags()) {
51  
-      foreach ($command->getFlags() as $flag) {
52  
-        $this->executeFlag($flag);
53  
-      }
54  
-    }
55  
-  }
56  
-  
57  
-  function getRegisteredTasks() {
58  
-    $list = array();
59  
-    $alltasks = array_merge($this->tasklists, $this->tasklists_n);
60  
-    foreach ($alltasks as $namespace => $tasklist) {
61  
-      $refclass = new \ReflectionClass(get_class($tasklist));
62  
-      $methods = $refclass->getMethods();
63  
-      foreach ($methods as $method) {
64  
-        $name = $method->getName();
65  
-        if (strpos($name, 'task') === 0) {
66  
-          $n_name = $this->utilities->dashLowerCase(substr($name, 4));
67  
-          $list[] = is_string($namespace) ? "$namespace:$n_name" : $n_name;
68  
-        }
69  
-      }
70  
-    }
71  
-    return $list;
72  
-  }
73  
-  
74  
-  private function executeFlag($flag) {
75  
-    $tasklists = $this->getAllTaskLists();
76  
-    foreach ($tasklists as $tasklist) {
77  
-      $method = 'flag' . $this->utilities->camelCase($flag);
78  
-      $this->invokeTaskMethod($tasklist, $method, array());
79  
-    }
80  
-  }
81  
-  
82  
-  private function getAllTaskLists() {
83  
-    return array_merge($this->tasklists, $this->tasklists_n);
84  
-  }
85  
-  
86  
-  private function invokeTaskMethod($tasklist, $method, $args) {
87  
-    if (method_exists($tasklist, $method)) {
88  
-      call_user_func_array(
89  
-        array($tasklist, $method), $args
90  
-      );
91  
-      return true;
92  
-    }
93  
-    return false;
94  
-  }
95  
-  
96  
-}
35  src/Troupe/Cli/Interpreter.php
... ...
@@ -1,35 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-use \Troupe\Cli\Command;
5  
-
6  
-class Interpreter {
7  
-  
8  
-  function interpret(array $args) {
9  
-    $result = array();
10  
-    $result['caller'] = array_shift($args);
11  
-    $flags = array();
12  
-    $arguments = array();
13  
-    $is_command_found = false;
14  
-    foreach ($args as $arg) {
15  
-      if ($is_command_found) {
16  
-        $arguments[] = $arg;
17  
-      } elseif (strpos($arg, '--') === 0) {
18  
-        $flags[] = substr($arg, 2);
19  
-      } else {
20  
-        $colon = strpos($arg, ':');
21  
-        if ($colon > 0) {
22  
-          $result['namespace'] = substr($arg, 0, $colon);
23  
-          $result['command'] = substr($arg, $colon + 1);
24  
-        } else {
25  
-          $result['command'] = $arg;
26  
-        }
27  
-        $is_command_found = true;
28  
-      } 
29  
-    }
30  
-    $result['flags']     = $flags;
31  
-    $result['arguments'] = $arguments;
32  
-    return new Command($result);
33  
-  }
34  
-
35  
-}
8  src/Troupe/Cli/Tasks.php
... ...
@@ -1,8 +0,0 @@
1  
-<?php
2  
-
3  
-namespace Troupe\Cli;
4  
-
5  
-interface Tasks {
6  
-  function getTaskNamespace();
7  
-  function setController($controller);
8  
-}
17  src/Troupe/Cli/TroupeTasks.php
@@ -5,34 +5,35 @@
5 5
 use \Troupe\SystemUtilities;
6 6
 use \Troupe\Manager;
7 7
 use \Troupe\Output;
  8
+use \Silly\Tasks;
8 9
 
9 10
 class TroupeTasks implements Tasks {
10 11
 
11 12
   private $controller, $output, $manager;
12  
-  
  13
+
13 14
   function __construct(Output $output, Manager $manager) {
14 15
     $this->output = $output;
15 16
     $this->manager = $manager;
16 17
   }
17  
-  
  18
+
18 19
   function getTaskNamespace() {
19 20
     return '';
20 21
   }
21  
-  
22  
-  function setController($controller) {
  22
+
  23
+  function setController(\Silly\Controller $controller) {
23 24
     $this->controller = $controller;
24 25
   }
25  
-  
  26
+
26 27
   function taskAssemble() {
27 28
     $this->manager->importDependencies();
28 29
   }
29  
-  
  30
+
30 31
   function taskList() {
31 32
     $this->manager->outputDependencies();
32 33
   }
33  
-  
  34
+
34 35
   function taskUpdate() {
35 36
     $this->manager->updateDependencies();
36 37
   }
37  
-  
  38
+
38 39
 }
7  src/Troupe/Container.php
@@ -166,18 +166,17 @@ private function defineGraph() {
166 166
     });
167 167
 
168 168
     $this['CliController'] = function(\Pimple $c) {
169  
-      return new Cli\Controller(
170  
-        $c['CliInterpreter'], $c['CliExecutor'], $c['project_root_dir']
171  
-      );
  169
+      return \Silly\Silly::getController($c['TroupeTaskList'], $c['project_root_dir']);
172 170
     };
173 171
 
  172
+    /*
174 173
     $this['CliInterpreter'] = function(\Pimple $c) {
175 174
       return new Cli\Interpreter;
176 175
     };
177 176
 
178 177
     $this['CliExecutor'] = function(\Pimple $c) {
179 178
       return new Cli\Executor($c['Utilities']);
180  
-    };
  179
+    };*/
181 180
 
182 181
     $this['FileWriter'] = function(\Pimple $c) {
183 182
       return new FileWriter;
10  src/Troupe/EnvironmentHelper.php
@@ -3,20 +3,20 @@
3 3
 namespace Troupe;
4 4
 
5 5
 class EnvironmentHelper {
6  
-  
  6
+
7 7
   private $cli, $args, $tasklists;
8  
-  
9  
-  function __construct(\Troupe\Cli\Controller $cli, array $args, array $tasklists) {
  8
+
  9
+  function __construct(\Silly\Controller $cli, array $args, array $tasklists) {
10 10
     $this->cli = $cli;
11 11
     $this->args = $args;
12 12
     $this->tasklists = $tasklists;
13 13
   }
14  
-  
  14
+
15 15
   function run() {
16 16
     foreach ($this->tasklists as $tasklist) {
17 17
       $this->cli->register($tasklist);
18 18
     }
19 19
     $this->cli->execute($this->args);
20 20
   }
21  
-  
  21
+
22 22
 }
103  tests/Troupe/Tests/Unit/Cli/ControllerTest.php
... ...
@@ -1,103 +0,0 @@
1  
-<?php
2  
-namespace Troupe\Tests\Unit\Cli;
3  
-
4  
-require_once realpath(__DIR__ . '/../../../../bootstrap.php');
5  
-
6  
-use \Troupe\Cli\Command;
7  
-use \Troupe\Cli\Executor;
8  
-use \Troupe\Cli\Controller;
9  
-
10  
-class ControllerTest extends \Troupe\Tests\TestCase {
11  
-  
12  
-  function setUp() {
13  
-    // This is called to help the reflector
14  
-    $this->getMock('Troupe\Cli\Tasks');
15  
-    $this->interpreter = $this->getMock('Troupe\Cli\Interpreter');
16  
-    $this->executor = $this->getMock(
17  
-      'Troupe\Cli\Executor', array(), array(), '', false
18  
-    );
19  
-    $this->dir = realpath(dirname(__FILE__));
20  
-    $this->cli = new Controller($this->interpreter, $this->executor, $this->dir);
21  
-  }
22  
-  
23  
-  function mock($methods = array()) {
24  
-    return $this->getMock('\Troupe\Cli\Controller', $methods, array(), '', false);
25  
-  }
26  
-  
27  
-  function mockTaskList($methods = array()) {
28  
-    return $this->getMock(
29  
-      'Troupe\Cli\Tasks',
30  
-      array_merge($methods, array('setController', 'getTaskNamespace'))
31  
-    );
32  
-  }
33  
-
34  
-  function testExecutePassesArgumentsToInterpreter() {
35  
-    $arguments = array(
36  
-      '/cli/ui/front', '--aflag'
37  
-    );
38  
-    $command = new Command(array());
39  
-    $this->interpreter->expects($this->once())
40  
-      ->method('interpret')
41  
-      ->with($this->equalto($arguments))
42  
-      ->will($this->returnValue($command));
43  
-    $this->cli->execute($arguments);
44  
-  }
45  
-  
46  
-  function testExecutePassesCommandFromInterpreterToExecutor() {
47  
-    $command = new Command(array());
48  
-    $this->interpreter->expects($this->once())
49  
-      ->method('interpret')
50  
-      ->will($this->returnValue($command));
51  
-    $this->executor->expects($this->once())
52  
-      ->method('execute')
53  
-      ->with($command);
54  
-    $this->cli->execute(array());
55  
-  }
56  
-  
57  
-  function testRegisterPassesItselfToTaskListAsController() {
58  
-    $tasks = $this->mockTaskList();
59  
-    $tasks->expects($this->once())
60  
-      ->method('setController')
61  
-      ->with($this->equalTo($this->cli));
62  
-    $this->executor->expects($this->once())
63  
-      ->method('registerTasks')
64  
-      ->with($tasks);
65  
-    $this->cli->register($tasks);
66  
-  }
67  
-  
68  
-  function testRegisterPassesNamespaceToExecutorRegisterTasks() {
69  
-    $tasks = $this->getMock('Troupe\Cli\Tasks');
70  
-    $tasks->expects($this->once())
71  
-      ->method('getTaskNamespace')
72  
-      ->will($this->returnValue('foo'));
73  
-    $this->executor->expects($this->once())
74  
-      ->method('registerTasks')
75  
-      ->with($tasks, 'foo');
76  
-    $this->cli->register($tasks);
77  
-  }
78  
-  
79  
-  function testOutput() {
80  
-    $test_string  = 'Foo bar.';
81  
-    $test_string2 = 'Bar foo.';
82  
-    ob_start();
83  
-    $this->cli->out($test_string);
84  
-    $this->cli->out($test_string2);
85  
-    $out = ob_get_clean();
86  
-    $this->assertEquals("$test_string\n$test_string2\n", $out);
87  
-  }
88  
-  
89  
-  function testGetRegisteredTasks() {
90  
-    $tasks = array('foo', 'bar');
91  
-    $this->executor->expects($this->once())
92  
-      ->method('getRegisteredTasks')
93  
-      ->will($this->returnValue($tasks));
94  
-    $this->assertEquals($tasks, $this->cli->getRegisteredTasks());
95  
-  }
96  
-  
97  
-  function testGettingWorkingDirectory() {
98  
-    $this->assertEquals(
99  
-      $this->dir, $this->cli->getWorkingDirectory()
100  
-    );
101  
-  }
102  
-  
103  
-}
123  tests/Troupe/Tests/Unit/Cli/ExecutorTest.php
... ...
@@ -1,123 +0,0 @@
1  
-<?php
2  
-namespace Troupe\Tests\Unit\Cli;
3  
-
4  
-require_once realpath(__DIR__ . '/../../../../bootstrap.php');
5  
-
6  
-use \Troupe\Cli\Command;
7  
-use \Troupe\Cli\Executor;
8  
-use \Troupe\Utilities;
9  
-
10  
-
11  
-class ExecutorTest extends \Troupe\Tests\TestCase {
12  
-
13  
-  function setUp() {
14  
-    $this->executor = new Executor(new Utilities);
15  
-  }
16  
-  
17  
-  function mockTaskList($methods = array()) {
18  
-    return $this->getMock(
19  
-      'Troupe\Cli\Tasks',
20  
-      array_merge($methods, array('setController', 'getTaskNamespace'))
21  
-    );
22  
-  }
23  
-  
24  
-  function testInvokingTaskMethodThroughExecute() {
25  
-    $tasks = $this->mockTaskList(array('taskCreateProjectDirectories'));
26  
-    $tasks->expects($this->once())
27  
-      ->method('taskCreateProjectDirectories')
28  
-      ->with($this->equalTo('adirectory'));
29  
-    $this->executor->registerTasks($tasks);
30  
-    $this->executor->execute(new Command(array(
31  
-      'caller'    => '/yo',
32  
-      'command'   => 'create-project-directories',
33  
-      'arguments' => array('adirectory')
34  
-    )));
35  
-  }
36  
-  
37  
-  function testInvokingDuplicateTaskMethods() {
38  
-    $tasks1 = $this->mockTaskList(array('taskDummyTask'));
39  
-    $tasks2 = $this->mockTaskList(array('taskDummyTask'));
40  
-    $tasks1->expects($this->never())
41  
-      ->method('taskDummyTask');
42  
-    $tasks2->expects($this->once())
43  
-      ->method('taskDummyTask')
44  
-      ->with($this->equalTo('adirectory'));
45  
-    $this->executor->registerTasks($tasks1);
46  
-    $this->executor->registerTasks($tasks2);
47  
-    $this->executor->execute(new Command(array(
48  
-      'caller'    => '/yo',
49  
-      'command'   => 'dummy-task',
50  
-      'arguments' => array('adirectory')
51  
-    )));
52  
-  }
53  
-  
54  
-  function testInvokingTaskMethodWithNameSpace() {
55  
-    $tasks = $this->mockTaskList(array('taskCreateProjectDirectories'));
56  
-    $tasks->expects($this->once())
57  
-      ->method('taskCreateProjectDirectories')
58  
-      ->with($this->equalTo('adirectory'));
59  
-    $this->executor->registerTasks($tasks, 'foo');
60  
-    $this->executor->execute(new Command(array(
61  
-      'caller'    => '/yo',
62  
-      'namespace' => 'foo',
63  
-      'command'   => 'create-project-directories',
64  
-      'arguments' => array('adirectory')
65  
-    )));
66  
-  }
67  
-  
68  
-  function testInvokingTaskMethodWithoutNamespaceThrowsUndefined() {
69  
-    $this->setExpectedException(
70  
-		  'Troupe\Cli\Exception\UndefinedTask'
71  
-	  );
72  
-    $tasks = $this->mockTaskList(array('taskCreateProjectDirectories'));
73  
-    $tasks->expects($this->never())
74  
-      ->method('taskCreateProjectDirectories');
75  
-    $this->executor->registerTasks($tasks, 'foo');
76  
-    $this->executor->execute(new Command(array(
77  
-      'caller'    => '/yo',
78  
-      'command'   => 'create-project-directories',
79  
-      'arguments' => array('adirectory')
80  
-    )));
81  
-  }
82  
-  
83  
-  function testThrowAsarUtilityCliExceptionWhenTaskMethodIsNotDefined() {
84  
-    $this->setExpectedException(
85  
-		  'Troupe\Cli\Exception\UndefinedTask',
86  
-		  "The task method 'taskSomethingToDoButCannotDo' is not defined."
87  
-	  );
88  
-	  $this->executor->execute(new Command(array(
89  
-	    'caller'  => '/a',
90  
-	    'command' => 'something-to-do-but-cannot-do',
91  
-	    'arguments' => 'arg1'
92  
-	  )));
93  
-  }
94  
-  
95  
-  function testInvokingFlagMethodThroughExecute() {
96  
-    $tasks = $this->mockTaskList(array('flagDoSomething'));
97  
-    $tasks->expects($this->once())
98  
-      ->method('flagDoSomething');
99  
-    $this->executor->registerTasks($tasks);
100  
-    $this->executor->execute(new Command(array(
101  
-      'caller'    => '/yo',
102  
-      'flags'   => array('do-something'),
103  
-    )));
104  
-  }
105  
-  
106  
-  function testReturningRegisteredTasks() {
107  
-    $tasks1 = $this->mockTaskList(array('taskDummyTask1'));
108  
-    $tasks2 = $this->mockTaskList(array('taskDummyTask2'));
109  
-    $tasks3 = $this->mockTaskList(array('taskDummyTask3'));
110  
-    $tasks4 = $this->mockTaskList(array('taskDummyTask4', 'taskDummyTask5'));
111  
-    $this->executor->registerTasks($tasks1);
112  
-    $this->executor->registerTasks($tasks2, null);
113  
-    $this->executor->registerTasks($tasks3, 'foo');
114  
-    $this->executor->registerTasks($tasks4, 'bar');
115  
-    $this->assertEquals(
116  
-      array(
117  
-        'dummy-task1', 'dummy-task2', 'foo:dummy-task3',
118  
-        'bar:dummy-task4', 'bar:dummy-task5'
119  
-      ),
120  
-      $this->executor->getRegisteredTasks()
121  
-    );
122  
-  }
123  
-}
93  tests/Troupe/Tests/Unit/Cli/InterpreterTest.php
... ...
@@ -1,93 +0,0 @@
1  
-<?php
2  
-namespace Troupe\Tests\Unit\Cli;
3  
-
4  
-require_once realpath(__DIR__ . '/../../../../bootstrap.php');
5  
-
6  
-use \Troupe\Cli\Command;
7  
-use \Troupe\Cli\Interpreter;
8  
-
9  
-
10  
-
11  
-class InterpreterTest extends \Troupe\Tests\TestCase {
12  
-
13  
-  function setUp() {
14  
-    $this->interpreter = new Interpreter;
15  
-  }
16  
-  
17  
-  /**
18  
-   * @dataProvider dataInterpretingCommands
19  
-   */
20  
-  function testInterpretingCommands($arguments, $expected) {
21  
-    $this->assertEquals(
22  
-      $expected, $this->interpreter->interpret($arguments)
23  
-    );
24  
-  }
25  
-  
26  
-  function dataInterpretingCommands() {
27  
-    return array(
28  
-      array(
29  
-        array(
30  
-          '/the/cli/caller', '--flag1', '--flag2', 'the-command', 'arg1', 'arg2'
31  
-        ),
32  
-        new Command(array(
33  
-          'caller'    => '/the/cli/caller',
34  
-          'flags'     => array('flag1', 'flag2'),
35  
-          'command'   => 'the-command',
36  
-          'arguments' => array('arg1', 'arg2')
37  
-        ))
38  
-      ),
39  
-      
40  
-      array(
41  
-        array(
42  
-          '/the/cli/callerx', '--flag1', 'a-command'
43  
-        ),
44  
-        new Command(array(
45  
-          'caller'    => '/the/cli/callerx',
46  
-          'flags'     => array('flag1'),
47  
-          'command'   => 'a-command',
48  
-          'arguments' => array()
49  
-        ))
50  
-      ),
51  
-      
52  
-      array(
53  
-        array(
54  
-          '/another/caller', 'mycommand', 'arg1', 'arg2'
55  
-        ),
56  
-        new Command(array(
57  
-          'caller'    => '/another/caller',
58  
-          'flags'     => array(),
59  
-          'command'   => 'mycommand',
60  
-          'arguments' => array('arg1', 'arg2')
61  
-        ))
62  
-      ),
63  
-      
64  
-      array(
65  
-        array(
66  
-          '/another/caller', 'mycommand', '--command-flag', 'arg2'
67  
-        ),
68  
-        new Command(array(
69  
-          'caller'    => '/another/caller',
70  
-          'flags'     => array(),
71  
-          'command'   => 'mycommand',
72  
-          'arguments' => array('--command-flag', 'arg2')
73  
-        ))
74  
-      ),
75  
-      
76  
-      array(
77  
-        array(
78  
-          '/caller', 'nspace:mycommand', 'arg1', 'arg2'
79  
-        ),
80  
-        new Command(array(
81  
-          'caller'    => '/caller',
82  
-          'flags'     => array(),
83  
-          'namespace' => 'nspace',
84  
-          'command'   => 'mycommand',
85  
-          'arguments' => array('arg1', 'arg2')
86  
-        ))
87  
-      )
88  
-      
89  
-    );
90  
-  }
91  
-  
92  
-  
93  
-}
1  tests/bootstrap.php
@@ -6,4 +6,5 @@
6 6
 $classLoader->register();
7 7
 $classLoader = new SplClassLoader('Pimple', $src_path . '/Pimple/lib');
8 8
 $classLoader->register();
  9
+require_once 'Silly/Silly.php';
9 10
 require_once 'Cibo/Cibo.php';

0 notes on commit 420adb1

Please sign in to comment.
Something went wrong with that request. Please try again.