99% of 615OPs |
100% of 69Lines |
96% of 52Branches |
80% of 20Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\report\fields\test\event\tap::__construct() | 28 | 100% | 12 | 100% | 1 | 0% | 1 | 100% |
| mageekguy\atoum\report\fields\test\event\tap::__toString() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\report\fields\test\event\tap::handleEvent() | 581 | 98% | 56 | 100% | 50 | 98% | 18 | 78% |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum\report\fields\test\event; |
| 4 |
|
| 5 |
use |
| 6 |
mageekguy\atoum, |
| 7 |
mageekguy\atoum\test, |
| 8 |
mageekguy\atoum\runner, |
| 9 |
mageekguy\atoum\report, |
| 10 |
mageekguy\atoum\exceptions |
| 11 |
; |
| 12 |
|
| 13 |
class tap extends report\fields\event |
| 14 |
{
|
| 15 |
protected $testPoint = 0; |
| 16 |
protected $testLine = ''; |
| 17 |
|
| 18 |
public function __construct()100% |
| 19 |
{
|
| 20 |
parent::__construct(array( |
| 21 |
runner::runStart, |
| 22 |
test::fail, |
| 23 |
test::error, |
| 24 |
test::void, |
| 25 |
test::uncompleted, |
| 26 |
test::skipped, |
| 27 |
test::exception, |
| 28 |
test::runtimeException, |
| 29 |
test::success |
| 30 |
) |
| 31 |
); |
| 32 |
} |
| 33 |
|
| 34 |
public function __toString()100% |
| 35 |
{
|
| 36 |
return $this->testLine; |
| 37 |
} |
| 38 |
|
| 39 |
public function handleEvent($event, atoum\observable $observable)100% |
| 40 |
{
|
| 41 |
$eventHandled = parent::handleEvent($event, $observable); |
| 42 |
|
| 43 |
if ($eventHandled === true) |
| 44 |
{
|
| 45 |
switch ($this->event) |
| 46 |
{
|
| 47 |
case runner::runStart: |
| 48 |
$this->testPoint = 0; |
| 49 |
$this->testLine = ''; |
| 50 |
break; |
| 51 |
|
| 52 |
case test::success: |
| 53 |
$this->testLine = 'ok ' . ++$this->testPoint . PHP_EOL; |
| 54 |
$this->testLine .= '# ' . $observable->getClass() . '::' . $observable->getCurrentMethod() . '()' . PHP_EOL; |
| 55 |
break; |
| 56 |
|
| 57 |
case test::error: |
| 58 |
$lastError = $observable->getScore()->getLastErroredMethod(); |
| 59 |
$lastErrorType = atoum\asserters\error::getAsString($lastError['type']); |
| 60 |
|
| 61 |
$this->testLine = 'not ok ' . ++$this->testPoint . ' - ' . trim($lastError['class']) . '::' . trim($lastError['method']) . '()' . PHP_EOL . '# ' . $lastErrorType . ' : ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastError['message'])) . PHP_EOL; |
| 62 |
$this->testLine .= '# ' . (isset($lastError['errorFile']) ? $lastError['errorFile'] : $lastError['file']) . ':' . (isset($lastError['errorLine']) ? $lastError['errorLine'] : $lastError['line']) . PHP_EOL; |
| 63 |
break; |
| 64 |
|
| 65 |
case test::fail: |
| 66 |
$lastFailAssertion = $observable->getScore()->getLastFailAssertion(); |
| 67 |
$this->testLine = 'not ok ' . ++$this->testPoint . ' - ' . trim($lastFailAssertion['class']) . '::' . trim($lastFailAssertion['method']) . '()' . PHP_EOL . '# ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastFailAssertion['fail'])) . PHP_EOL; |
| 68 |
$this->testLine .= '# ' . $lastFailAssertion['file'] . ':' . $lastFailAssertion['line'] . PHP_EOL; |
| 69 |
break; |
| 70 |
|
| 71 |
case test::void: |
| 72 |
$lastVoidMethod = $observable->getScore()->getLastVoidMethod(); |
| 73 |
$this->testLine = 'not ok ' . ++$this->testPoint . ' # TODO ' . trim($lastVoidMethod['class']) . '::' . trim($lastVoidMethod['method']) . '()' . PHP_EOL; |
| 74 |
$this->testLine .= '# ' . $lastVoidMethod['file'] . PHP_EOL; |
| 75 |
break; |
| 76 |
|
| 77 |
case test::uncompleted: |
| 78 |
$lastUncompleteMethod = $observable->getScore()->getLastUncompleteMethod(); |
| 79 |
$lastError = $observable->getScore()->getLastErroredMethod(); |
| 80 |
|
| 81 |
$this->testLine = 'not ok ' . ++$this->testPoint . ' - ' . trim($lastUncompleteMethod['class']) . '::' . trim($lastUncompleteMethod['method']) . '()' . PHP_EOL; |
| 82 |
|
| 83 |
if ($lastError['class'] === $lastUncompleteMethod['class'] && $lastError['method'] === $lastUncompleteMethod['method']) |
| 84 |
{
|
| 85 |
$this->testLine .= '# ' . $lastError['type'] . ' : ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastError['message'])) . PHP_EOL; |
| 86 |
} |
| 87 |
else |
| 88 |
{
|
| 89 |
$this->testLine .= '# ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastUncompleteMethod['output']) ?: 'uncomplete method') . PHP_EOL; |
| 90 |
} |
| 91 |
|
| 92 |
$this->testLine .= '# ' . $lastUncompleteMethod['file'] . PHP_EOL; |
| 93 |
break; |
| 94 |
|
| 95 |
case test::skipped: |
| 96 |
$lastSkippedMethod = $observable->getScore()->getLastSkippedMethod(); |
| 97 |
$this->testLine = 'ok ' . ++$this->testPoint . ' # SKIP ' . trim($lastSkippedMethod['class']) . '::' . trim($lastSkippedMethod['method']) . '()' . PHP_EOL . '# ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastSkippedMethod['message'])) . PHP_EOL; |
| 98 |
$this->testLine .= '# ' . $lastSkippedMethod['file'] . ':' . $lastSkippedMethod['line'] . PHP_EOL; |
| 99 |
break; |
| 100 |
|
| 101 |
case test::exception: |
| 102 |
$lastException = $observable->getScore()->getLastException(); |
| 103 |
$this->testLine = 'not ok ' . ++$this->testPoint . ' - ' . trim($lastException['class']) . '::' . trim($lastException['method']) . '()' . PHP_EOL . '# ' . str_replace(PHP_EOL, PHP_EOL . '# ', trim($lastException['value'])) . PHP_EOL; |
| 104 |
$this->testLine .= '# ' . $lastException['file'] . ':' . $lastException['line'] . PHP_EOL; |
| 105 |
break; |
| 106 |
|
| 107 |
case test::runtimeException: |
| 108 |
$lastRuntimeException = $observable->getScore()->getLastRuntimeException(); |
| 109 |
$this->testLine = 'Bail out!' . ($lastRuntimeException->getMessage() ? ' ' . trim($lastRuntimeException->getMessage()) : '') . PHP_EOL; |
| 110 |
break; |
| 111 |
} |
| 112 |
} |
| 113 |
|
| 114 |
return $eventHandled; |
| 115 |
} |
| 116 |
} |