Refactored DirectoryControllerTest to improve coverage

This commit is contained in:
Chris Kankiewicz
2020-01-08 21:48:05 -07:00
parent 5c0cfcabf9
commit 11d887321e
2 changed files with 36 additions and 5 deletions

View File

@@ -13,8 +13,16 @@ use Tests\TestCase;
class DirectoryControllerTest extends TestCase
{
public function test_it_returns_a_successful_response(): void
{
/** @dataProvider configOptions */
public function test_it_returns_a_successful_response(
bool $hideAppFiles,
bool $hideVcsFiles,
bool $displayReadmes
): void {
$this->config->set('app.hide_app_files', $hideAppFiles);
$this->config->set('app.hide_vcs_files', $hideVcsFiles);
$this->config->set('app.display_readmes', $displayReadmes);
$this->container->call(TwigProvider::class);
$controller = new DirectoryController(
@@ -33,8 +41,16 @@ class DirectoryControllerTest extends TestCase
$this->assertEquals(200, $response->getStatusCode());
}
public function test_it_returns_a_successful_response_when_listing_a_subdirectory(): void
{
/** @dataProvider configOptions */
public function test_it_returns_a_successful_response_when_listing_a_subdirectory(
bool $hideAppFiles,
bool $hideVcsFiles,
bool $displayReadmes
): void {
$this->config->set('app.hide_app_files', $hideAppFiles);
$this->config->set('app.hide_vcs_files', $hideVcsFiles);
$this->config->set('app.display_readmes', $displayReadmes);
$this->container->call(TwigProvider::class);
$controller = new DirectoryController(
@@ -75,7 +91,7 @@ class DirectoryControllerTest extends TestCase
$this->assertEquals(404, $response->getStatusCode());
}
public function test_it_returns_a_successful_response_for_a_search(): void
public function test_it_returns_a_successful_response_for_a_search_request(): void
{
$this->container->call(TwigProvider::class);
@@ -99,4 +115,18 @@ class DirectoryControllerTest extends TestCase
$this->assertInstanceOf(ResponseInterface::class, $response);
$this->assertEquals(200, $response->getStatusCode());
}
public function configOptions(): array
{
return [
[true, false, false],
[true, true, false],
[true, false, true],
[true, true, true],
[false, true, false],
[false, true, true],
[false, false, true],
[false, false, false],
];
}
}

View File

@@ -34,6 +34,7 @@ class TestCase extends PHPUnitTestCase
'hidden_files' => [],
'hide_app_files' => true,
'hide_vcs_files' => false,
'display_readmes' => false,
'max_hash_size' => 1000000000,
],
'view' => [