Skip to content

Commit cff1768

Browse files
committed
cleanup and test fixes
1 parent f50627e commit cff1768

File tree

5 files changed

+25
-26
lines changed

5 files changed

+25
-26
lines changed

examples/complex.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ protected function setup(Options $options)
2727
$options->registerOption('someflag', 'This is a flag only valid for the foo command', 's', false, 'foo');
2828
$options->registerArgument('file', 'This argument is only required for the foo command', true, 'foo');
2929

30-
$options->registerOption('load', 'Another flag only for the bar command, requiring an argument', 'l', 'input', 'bar');
30+
$options->registerOption('load', 'Another flag only for the bar command, requiring an argument', 'l', 'input',
31+
'bar');
3132

3233
}
3334

@@ -56,7 +57,7 @@ protected function main(Options $options)
5657
}
5758

5859
$this->info('$options->getArgs():');
59-
var_dump($options->getArgs());
60+
var_dump($options->getArgs());
6061

6162
}
6263
}

examples/simple.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,8 @@ protected function main(Options $options)
4444
$this->info("file was given as " . $options->getOpt('file'));
4545
}
4646

47-
$this->info("Number of arguments: ".count($options->getArgs()));
48-
47+
$this->info("Number of arguments: " . count($options->getArgs()));
48+
4949
$this->success("main finished");
5050
}
5151
}

src/CLI.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ abstract class CLI
2525
*
2626
* @param bool $autocatch should exceptions be catched and handled automatically?
2727
*/
28-
public function __construct($autocatch=true)
28+
public function __construct($autocatch = true)
2929
{
30-
if($autocatch) {
30+
if ($autocatch) {
3131
set_exception_handler(array($this, 'fatal'));
3232
}
3333

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,14 @@
11
<?php
22

3-
use splitbrain\phpcli\Options;
3+
namespace splitbrain\phpcli\tests;
44

5-
class OptionsTest extends PHPUnit_Framework_TestCase
5+
class Options extends \splitbrain\phpcli\Options
6+
{
7+
8+
public $args;
9+
}
10+
11+
class OptionsTest extends \PHPUnit_Framework_TestCase
612
{
713

814
function test_simpleshort()
Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,27 +76,19 @@ public function test_calc($input, $expect, $max = 100, $border = ' ')
7676

7777
}
7878

79-
/**
80-
* check that color codes are not used when calculating string lengths
81-
*/
82-
public function test_strlen()
83-
{
84-
$tf = new TableFormatter();
85-
$this->assertEquals(strlen("this is red!"), $tf->strlen("this is \33[0;31mred\33[0m!"));
86-
}
87-
8879
/**
8980
* Check wrapping
9081
*/
91-
public function test_wrap() {
92-
$text = "this is a long string something\n".
93-
"123456789012345678901234567890";
94-
95-
$expt = "this is a long\n".
96-
"string\n".
97-
"something\n".
98-
"123456789012345\n".
99-
"678901234567890";
82+
public function test_wrap()
83+
{
84+
$text = "this is a long string something\n" .
85+
"123456789012345678901234567890";
86+
87+
$expt = "this is a long\n" .
88+
"string\n" .
89+
"something\n" .
90+
"123456789012345\n" .
91+
"678901234567890";
10092

10193
$tf = new TableFormatter();
10294
$this->assertEquals($expt, $tf->wordwrap($text, 15, "\n", true));

0 commit comments

Comments
 (0)