100% of 412OPs |
100% of 40Lines |
93% of 14Branches |
100% of 8Paths |
| Method | OPs | OPs % | Lines | Line % | Branches | Branches % | Paths | Path % |
|---|---|---|---|---|---|---|---|---|
| mageekguy\atoum\report\fields\runner\result\notifier::__construct() | 16 | 100% | 3 | 100% | 1 | 0% | 1 | 100% |
| mageekguy\atoum\report\fields\runner\result\notifier::__toString() | 23 | 100% | 2 | 100% | 5 | 100% | 2 | 100% |
| mageekguy\atoum\report\fields\runner\result\notifier::notify() | 310 | 100% | 25 | 100% | 5 | 100% | 2 | 100% |
| mageekguy\atoum\report\fields\runner\result\notifier::setAdapter() | 16 | 100% | 3 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\report\fields\runner\result\notifier::getAdapter() | 6 | 100% | 1 | 100% | 1 | 100% | 1 | 100% |
| mageekguy\atoum\report\fields\runner\result\notifier::send() | 41 | 100% | 6 | 100% | 1 | 100% | 1 | 100% |
| # | |
|---|---|
| 1 |
<?php |
| 2 |
|
| 3 |
namespace mageekguy\atoum\report\fields\runner\result; |
| 4 |
|
| 5 |
use |
| 6 |
mageekguy\atoum, |
| 7 |
mageekguy\atoum\report\fields\runner\result |
| 8 |
; |
| 9 |
|
| 10 |
abstract class notifier extends result |
| 11 |
{
|
| 12 |
protected $adapter = null; |
| 13 |
|
| 14 |
public function __construct(atoum\adapter $adapter = null)100% |
| 15 |
{
|
| 16 |
parent::__construct(); |
| 17 |
|
| 18 |
$this->setAdapter($adapter); |
| 19 |
} |
| 20 |
|
| 21 |
public function __toString()100% |
| 22 |
{
|
| 23 |
$string = $this->notify(); |
| 24 |
|
| 25 |
return $string == '' ? '' : trim($string) . PHP_EOL; |
| 26 |
} |
| 27 |
|
| 28 |
public function notify()100% |
| 29 |
{
|
| 30 |
if ($this->success === true) |
| 31 |
{
|
| 32 |
$title = 'Success!'; |
| 33 |
$message = sprintf( |
| 34 |
$this->locale->_('%s %s %s %s %s'),
|
| 35 |
sprintf($this->locale->__('%s test', '%s tests', $this->testNumber), $this->testNumber) . PHP_EOL,
|
| 36 |
sprintf($this->locale->__('%s/%s method', '%s/%s methods', $this->testMethodNumber), $this->testMethodNumber - $this->voidMethodNumber - $this->skippedMethodNumber, $this->testMethodNumber) . PHP_EOL,
|
| 37 |
sprintf($this->locale->__('%s void method', '%s void methods', $this->voidMethodNumber), $this->voidMethodNumber) . PHP_EOL,
|
| 38 |
sprintf($this->locale->__('%s skipped method', '%s skipped methods', $this->skippedMethodNumber), $this->skippedMethodNumber) . PHP_EOL,
|
| 39 |
sprintf($this->locale->__('%s assertion', '%s assertions', $this->assertionNumber), $this->assertionNumber) . PHP_EOL
|
| 40 |
); |
| 41 |
} |
| 42 |
else |
| 43 |
{
|
| 44 |
$title = 'Failure!'; |
| 45 |
$message = sprintf( |
| 46 |
$this->locale->_('%s %s %s %s %s %s %s %s'),
|
| 47 |
sprintf($this->locale->__('%s test', '%s tests', $this->testNumber), $this->testNumber) . PHP_EOL,
|
| 48 |
sprintf($this->locale->__('%s/%s method', '%s/%s methods', $this->testMethodNumber), $this->testMethodNumber - $this->voidMethodNumber - $this->skippedMethodNumber - $this->uncompletedMethodNumber, $this->testMethodNumber) . PHP_EOL,
|
| 49 |
sprintf($this->locale->__('%s void method', '%s void methods', $this->voidMethodNumber), $this->voidMethodNumber) . PHP_EOL,
|
| 50 |
sprintf($this->locale->__('%s skipped method', '%s skipped methods', $this->skippedMethodNumber), $this->skippedMethodNumber) . PHP_EOL,
|
| 51 |
sprintf($this->locale->__('%s uncompleted method', '%s uncompleted methods', $this->uncompletedMethodNumber), $this->uncompletedMethodNumber) . PHP_EOL,
|
| 52 |
sprintf($this->locale->__('%s failure', '%s failures', $this->failNumber), $this->failNumber) . PHP_EOL,
|
| 53 |
sprintf($this->locale->__('%s error', '%s errors', $this->errorNumber), $this->errorNumber) . PHP_EOL,
|
| 54 |
sprintf($this->locale->__('%s exception', '%s exceptions', $this->exceptionNumber), $this->exceptionNumber) . PHP_EOL
|
| 55 |
); |
| 56 |
} |
| 57 |
|
| 58 |
return $this->send($title, $message, $this->success); |
| 59 |
} |
| 60 |
|
| 61 |
public function setAdapter(atoum\adapter $adapter = null) |
| 62 |
{
|
| 63 |
$this->adapter = $adapter ?: new atoum\adapter(); |
| 64 |
|
| 65 |
return $this; |
| 66 |
} |
| 67 |
|
| 68 |
public function getAdapter()100% |
| 69 |
{
|
| 70 |
return $this->adapter; |
| 71 |
} |
| 72 |
|
| 73 |
public function send($title, $message, $success)100% |
| 74 |
{
|
| 75 |
return $this->adapter->system(sprintf( |
| 76 |
$this->getCommand(), |
| 77 |
escapeshellarg($title), |
| 78 |
escapeshellarg($message), |
| 79 |
escapeshellarg($success) |
| 80 |
)); |
| 81 |
} |
| 82 |
|
| 83 |
protected abstract function getCommand(); |
| 84 |
} |