Skip to content

Commit

Permalink
Do not check empty passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
gisostallenberg committed Dec 2, 2015
1 parent d45af9b commit 5be41f0
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/CorrectHorseBatteryStaple.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@

namespace GisoStallenberg\CorrectHorseBatteryStaple;

use InvalidArgumentException;
use Symfony\Component\Process\Exception\ProcessFailedException;
use Symfony\Component\Process\Exception\RuntimeException;
use Symfony\Component\Process\Process;
use Symfony\Component\Process\ProcessBuilder;

class CorrectHorseBatteryStaple {
/**
Expand Down Expand Up @@ -78,6 +78,9 @@ private function verifyCommand() {
* @throws ProcessFailedException
*/
public function check($password) {
if (empty($password) ) {
throw new InvalidArgumentException('The password cannot be empty');
}
$process = new Process($this->command);
$process->setInput($password);
$process->mustRun();
Expand Down
10 changes: 10 additions & 0 deletions tests/CorrectHorseBatteryStapleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ public function testConstruct()
new CorrectHorseBatteryStaple();
}

/**
* Tests if checking an empty password fails
*
* @expectedException InvalidArgumentException
*/
public function testInvalidStringConstruct()
{
(new CorrectHorseBatteryStaple() )->check('');
}

/**
* Tests if the getters return expected results.
*
Expand Down

0 comments on commit 5be41f0

Please sign in to comment.