Skip to content

Commit 7fed858

Browse files
committed
Add base for unit tests
1 parent 1ed1de4 commit 7fed858

File tree

4 files changed

+57
-1
lines changed

4 files changed

+57
-1
lines changed

phpunit.xml.dist

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="tests/bootstrap.php"
13+
>
14+
<testsuites>
15+
<testsuite name="Symfony console completion">
16+
<directory>./tests</directory>
17+
</testsuite>
18+
</testsuites>
19+
<filter>
20+
<whitelist processUncoveredFilesFromWhitelist="true">
21+
<directory suffix=".php">src</directory>
22+
</whitelist>
23+
</filter>
24+
</phpunit>

src/Stecman/Component/Symfony/Console/BashCompletion/CompletionHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ protected function filterResults($array)
380380
* @param string $programName
381381
* @return string
382382
*/
383-
public function generateBashCompletionHook($programName)
383+
public function generateBashCompletionHook($programName = false)
384384
{
385385
global $argv;
386386
$command = $argv[0];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
class CompletionHandlerTest extends PHPUnit_Framework_TestCase {
4+
5+
public function testGenerateBashCompletionHook()
6+
{
7+
$handler = $this->getCompletionHandler();
8+
9+
$noArg = $handler->generateBashCompletionHook();
10+
$this->assertNotEmpty($noArg);
11+
12+
$withArg = $handler->generateBashCompletionHook('program');
13+
$this->assertNotEmpty($withArg);
14+
}
15+
16+
protected function getCompletionHandler()
17+
{
18+
$app = new \Symfony\Component\Console\Application();
19+
return new \Stecman\Component\Symfony\Console\BashCompletion\CompletionHandler($app);
20+
}
21+
22+
}

tests/bootstrap.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
$filename = __DIR__ . '/../vendor/autoload.php';
4+
5+
if (!file_exists($filename)) {
6+
echo 'You must first install the vendors using composer.' . PHP_EOL;
7+
exit(1);
8+
}
9+
10+
require_once $filename;

0 commit comments

Comments
 (0)