Updated from some -dev modules to alpha, beta or full releases
[yaffs-website] / vendor / psy / psysh / test / ShellTest.php
index 1fb78b230908407147b141e43d78f807b1764945..5b587d634f7b2b6522158d333f1b23910fdb062b 100644 (file)
@@ -380,6 +380,38 @@ class ShellTest extends \PHPUnit\Framework\TestCase
         ];
     }
 
+    /**
+     * @dataProvider commandsToHas
+     */
+    public function testHasCommand($command, $has)
+    {
+        $shell = new Shell($this->getConfig());
+
+        // :-/
+        $refl = new \ReflectionClass('Psy\\Shell');
+        $method = $refl->getMethod('hasCommand');
+        $method->setAccessible(true);
+
+        $this->assertEquals($method->invokeArgs($shell, [$command]), $has);
+    }
+
+    public function commandsToHas()
+    {
+        return [
+            ['help', true],
+            ['help help', true],
+            ['"help"', false],
+            ['"help help"', false],
+            ['ls -al ', true],
+            ['ls "-al" ', true],
+            ['ls"-al"', false],
+            [' q', true],
+            ['   q  --help', true],
+            ['"q"', false],
+            ['"q",', false],
+        ];
+    }
+
     private function getOutput()
     {
         $stream = fopen('php://memory', 'w+');