Expand test coverage.

This commit is contained in:
James Cole
2017-12-23 17:42:07 +01:00
parent 8bd76d1ff0
commit 08b743ddcb
82 changed files with 1413 additions and 142 deletions

View File

@@ -32,6 +32,8 @@ use Response;
class IntroController
{
/**
* Get the intro steps. There are currently no specific routes with an outro step.
*
* @param string $route
* @param string $specificPage
*
@@ -39,12 +41,15 @@ class IntroController
*/
public function getIntroSteps(string $route, string $specificPage = '')
{
Log::debug(sprintf('getIntroSteps for route "%s" and page "%s"', $route, $specificPage));
$steps = $this->getBasicSteps($route);
$specificSteps = $this->getSpecificSteps($route, $specificPage);
if (0 === count($specificSteps)) {
Log::debug(sprintf('No specific steps for route "%s" and page "%s"', $route, $specificPage));
return Response::json($steps);
}
if ($this->hasOutroStep($route)) {
// @codeCoverageIgnoreStart
// save last step:
$lastStep = $steps[count($steps) - 1];
// remove last step:
@@ -52,6 +57,7 @@ class IntroController
// merge arrays and add last step again
$steps = array_merge($steps, $specificSteps);
$steps[] = $lastStep;
// @codeCoverageIgnoreEnd
}
if (!$this->hasOutroStep($route)) {
$steps = array_merge($steps, $specificSteps);
@@ -68,13 +74,16 @@ class IntroController
public function hasOutroStep(string $route): bool
{
$routeKey = str_replace('.', '_', $route);
Log::debug(sprintf('Has outro step for route %s', $routeKey));
$elements = config(sprintf('intro.%s', $routeKey));
if (!is_array($elements)) {
return false;
}
$keys = array_keys($elements);
Log::debug('Elements is array', $elements);
Log::debug('Keys is', array_keys($elements));
Log::debug(sprintf('Keys has "outro": %s', var_export(in_array('outro', array_keys($elements)), true)));
return in_array('outro', $keys);
return in_array('outro', array_keys($elements));
}
/**
@@ -135,6 +144,7 @@ class IntroController
$steps[] = $currentStep;
}
}
Log::debug(sprintf('Total basic steps for %s is %d', $routeKey, count($steps)));
return $steps;
}
@@ -147,7 +157,8 @@ class IntroController
*/
private function getSpecificSteps(string $route, string $specificPage): array
{
$steps = [];
$steps = [];
$routeKey = '';
// user is on page with specific instructions:
if (strlen($specificPage) > 0) {
@@ -165,6 +176,7 @@ class IntroController
}
}
}
Log::debug(sprintf('Total specific steps for route "%s" and page "%s" (routeKey is "%s") is %d', $route, $specificPage, $routeKey, count($steps)));
return $steps;
}