From 0afefd0cc71d0c107edf371a6a3bdf5b3e36652f Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Sun, 4 Aug 2013 23:40:22 +0200 Subject: [PATCH] fix space between last date and number --- src/callnotifier/Logger/CallFileTop.php | 5 ++ tests/callnotifier/Logger/CallFileTopTest.php | 60 +++++++++++++++++++ 2 files changed, 65 insertions(+) create mode 100644 tests/callnotifier/Logger/CallFileTopTest.php diff --git a/src/callnotifier/Logger/CallFileTop.php b/src/callnotifier/Logger/CallFileTop.php index 4fd8917..1412782 100644 --- a/src/callnotifier/Logger/CallFileTop.php +++ b/src/callnotifier/Logger/CallFileTop.php @@ -67,8 +67,13 @@ class Logger_CallFileTop extends Logger_CallBase if (isset($arLines[0]) && $arLines[0] == $date) { //same date as previous log entry $arLines = array_pad($arLines, -count($arLines) - 1, ''); + } else if (!isset($arLines[0])) { + //empty file + $arLines = array_pad($arLines, -count($arLines) - 2, ''); } else { + //new date $arLines = array_pad($arLines, -count($arLines) - 3, ''); + $arLines[2] = "\n"; } $arLines[0] = $date; $arLines[1] = $logline; diff --git a/tests/callnotifier/Logger/CallFileTopTest.php b/tests/callnotifier/Logger/CallFileTopTest.php new file mode 100644 index 0000000..4011f00 --- /dev/null +++ b/tests/callnotifier/Logger/CallFileTopTest.php @@ -0,0 +1,60 @@ +type = 'i'; + $call->from = '03411234567'; + $call->to = '12345'; + $call->start = strtotime('2013-08-03 20:11'); + $call->end = strtotime('2013-08-03 20:12'); + $l->log('finishedCall', array('call' => $call)); + + $call = new CallMonitor_Call(); + $call->type = 'i'; + $call->from = '03411234567'; + $call->to = '12345'; + $call->start = strtotime('2013-08-03 21:13'); + $call->end = strtotime('2013-08-03 21:14'); + $l->log('finishedCall', array('call' => $call)); + + $call = new CallMonitor_Call(); + $call->type = 'i'; + $call->from = '03411234567'; + $call->to = '12345'; + $call->start = strtotime('2013-08-04 20:15'); + $call->end = strtotime('2013-08-04 20:16'); + $l->log('finishedCall', array('call' => $call)); + + $this->assertEquals( +<< -- 2.30.2