-
Notifications
You must be signed in to change notification settings - Fork 0
/
kahlan-config.php
48 lines (42 loc) · 1.35 KB
/
kahlan-config.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
declare(strict_types=1);
use Kahlan\Filter\Filters;
/** @var \Kahlan\Cli\Kahlan $this */
/** @var \Kahlan\Cli\CommandLine $cli */
$cli = $this->commandLine();
//Switch to Mockery for stubbing and mocking
$cli->set('include', []);
Filters::apply($this, 'run', function ($next)
{
Mockery::globalHelpers();
return $next();
});
//Update Kahlan default CLI options
$cli->option('grep', 'default', '*.spec.php');
$cli->option('reporter', 'default', 'verbose');
$cli->option('coverage', 'default', 3);
$cli->option('clover', 'default', 'spec_output/kahlan.coverage.xml');
//Register custom global helper functions
if (!function_exists('propertyByPath'))
{
function propertyByPath($object, array $path)
{
$pointer = $object;
foreach ($path as $index => $propertyName)
{
if (!is_object($pointer))
{
throw new LogicException(sprintf('Can not get property %s (%s) from non object', $propertyName, $index));
}
$classReflection = new ReflectionClass($pointer);
if (!$classReflection->hasProperty($propertyName))
{
throw new LogicException(sprintf('Class %s does not have property %s (%s)', $classReflection->getName(), $propertyName, $index));
}
$propertyReflection = $classReflection->getProperty($propertyName);
$propertyReflection->setAccessible(true);
$pointer = $propertyReflection->getValue($pointer);
}
return $pointer;
}
}