Skip to content

Commit

Permalink
Add test for ProgressHelper output with options.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed May 26, 2015
1 parent 31e95ec commit 7349342
Showing 1 changed file with 59 additions and 0 deletions.
59 changes: 59 additions & 0 deletions tests/TestCase/Shell/Helper/ProgressHelperTest.php
Expand Up @@ -75,6 +75,36 @@ public function testOutputSuccess()
$this->assertEquals($expected, $this->stub->messages());
}

/**
* Test output with options
*
* @return void
*/
public function testOutputSuccessOptions()
{
$this->helper->output([
'total' => 10,
'width' => 20,
'callback' => function ($progress) {
$progress->increment(2);
}
]);
$expected = [
'',
'==> 20%',
'',
'=====> 40%',
'',
'========> 60%',
'',
'===========> 80%',
'',
'==============> 100%',
'',
];
$this->assertEquals($expected, $this->stub->messages());
}

/**
* Test using the helper manually.
*
Expand Down Expand Up @@ -132,4 +162,33 @@ public function testIncrementWithNegatives()
];
$this->assertEquals($expected, $this->stub->messages());
}

/**
* Test increment and draw with options
*
* @return void
*/
public function testIncrementWithOptions()
{
$this->helper->init([
'total' => 10,
'width' => 20,
]);
$expected = [
'',
'=====> 40%',
'',
'===========> 80%',
'',
'==============> 100%',
];
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();
$this->helper->increment(4);
$this->helper->draw();

$this->assertEquals($expected, $this->stub->messages());
}
}

0 comments on commit 7349342

Please sign in to comment.