Skip to content

Commit

Permalink
[DefaultLogger] added unit test for buildFinished (#1164)
Browse files Browse the repository at this point in the history
* Added logger test.
* Related to #1161
  • Loading branch information
siad007 committed Oct 19, 2019
1 parent faecafd commit e43139e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion classes/phing/listener/DefaultLogger.php
Expand Up @@ -166,7 +166,7 @@ public function buildFinished(BuildEvent $event)
$msg = PHP_EOL . $this->getBuildFailedMessage() . PHP_EOL;
self::throwableMessage($msg, $error, Project::MSG_VERBOSE <= $this->msgOutputLevel);
}
$msg .= PHP_EOL . "Total time: " . self::formatTime(Phing::currentTimeMillis() - $this->startTime) . PHP_EOL;
$msg .= PHP_EOL . "Total time: " . static::formatTime(Phing::currentTimeMillis() - $this->startTime) . PHP_EOL;

if ($error === null) {
$this->printMessage($msg, $this->out, Project::MSG_VERBOSE);
Expand Down
22 changes: 22 additions & 0 deletions test/classes/phing/listener/DefaultLoggerTest.php
Expand Up @@ -66,4 +66,26 @@ public function throwableMessageThree()
static::msg($be, false)
);
}

/**
* @test
*/
public function buildFinished()
{
$event = new BuildEvent(new Project());
$logger = new class extends DefaultLogger {
public function printMessage($message, ?OutputStream $stream = null, $priority = null)
{
echo $message;
}

public static function formatTime($micros)
{
return 'TIME_STRING';
}
};
$msg = PHP_EOL . 'BUILD FINISHED' . PHP_EOL . PHP_EOL . 'Total time: TIME_STRING' . PHP_EOL;
$this->expectOutputString($msg);
$logger->buildFinished($event);
}
}

0 comments on commit e43139e

Please sign in to comment.