Skip to content

Commit

Permalink
Merge 3af031f into 2f1066d
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm authored Jan 30, 2019
2 parents 2f1066d + 3af031f commit 6842aa0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
]
},
"require-dev": {
"composer/composer": "dev-master",
"phpunit/phpunit": "^6.5",
"satooshi/php-coveralls": "^2.0",
"squizlabs/php_codesniffer": "^3.3"
Expand Down
38 changes: 38 additions & 0 deletions tests/Unit/UnitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,42 @@ public function testBadOutput()
$this->expectExceptionMessage('Invalid JSON found from parsing the security check data');
$checker->checkDirectory('/tmp');
}

public function testEmptyOutput()
{
$mock_process = $this->createMock(Process::class);
$mock_process->method('getOutput')
->willReturn('');
$mock_process_factory = $this->createMock(ProcessFactory::class);
$mock_process_factory->method('getProcess')
->willReturn($mock_process);
$checker = new SecurityChecker();
$checker->setProcessFactory($mock_process_factory);
$this->expectExceptionMessage('No output received from symfony command. This could mean you do not have the symfony command available. This is the stderr: ');
$checker->checkDirectory('/tmp');
}

public function testGoodOutput()
{
$mock_process = $this->createMock(Process::class);
$json_string = '[{"version": 2}]';
$mock_process->method('getOutput')
->willReturn($json_string);
$mock_process_factory = $this->createMock(ProcessFactory::class);
$mock_process_factory->method('getProcess')
->willReturn($mock_process);
$checker = new SecurityChecker();
$checker->setProcessFactory($mock_process_factory);
$json = $checker->checkDirectory('/tmp');
$this->assertEquals(json_decode($json_string, true), $json);
}

public function testGetProcess()
{
// OK, this is mostly for coverage.
$checker = new SecurityChecker();
$factory = $checker->getProcessFactory();
$this->assertTrue($factory instanceof ProcessFactory);
$this->assertTrue($factory->getProcess('true') instanceof Process);
}
}

0 comments on commit 6842aa0

Please sign in to comment.