From: Christian Weiske Date: Fri, 3 Aug 2012 15:09:39 +0000 (+0200) Subject: call notifier tests X-Git-Tag: v1.0.0~54 X-Git-Url: https://git.cweiske.de/auerswald-callnotifier.git/commitdiff_plain/49094ec613feb82d8b658e45bc957f042103f34f call notifier tests --- diff --git a/tests/callnotifier/CallMonitorTest.php b/tests/callnotifier/CallMonitorTest.php new file mode 100644 index 0000000..309a5e6 --- /dev/null +++ b/tests/callnotifier/CallMonitorTest.php @@ -0,0 +1,102 @@ +calls = array(); + + $config = new Config(); + + $log = new Log(); + $log->addLogger($this, array('startingCall', 'finishedCall')); + + $cm = new CallMonitor($config, $log); + $this->handler = new MessageHandler($config, $log, $cm); + } + + protected function loadDump($file) + { + $this->handler->config->replayFile = __DIR__ . '/../dumps/' . $file; + $source = new Source_File($this->handler->config, $this->handler); + $source->run(); + } + + + public function log($type, $arData) + { + $this->calls[$type][] = $arData['call']; + } + + + public function testIntCallToInt() + { + $this->loadDump('intern-22-zu-41.bin'); + $this->assertCallCount(1, 1); + + $this->assertFrom('22', $this->calls['startingCall'][0]); + $this->assertTo('**41', $this->calls['startingCall'][0]); + + $this->assertFrom('22', $this->calls['finishedCall'][0]); + $this->assertTo('**41', $this->calls['finishedCall'][0]); + } + + public function testIntCallToExternal() + { + $this->loadDump('intern-analog-zu-handy.bin'); + $this->assertCallCount(1, 1); + + $this->assertFrom('40862', $this->calls['startingCall'][0]); + $this->assertTo('01634779878', $this->calls['startingCall'][0]); + + $this->assertFrom('40862', $this->calls['finishedCall'][0]); + $this->assertTo('01634779878', $this->calls['finishedCall'][0]); + } + + public function testExtCallToIntGroup() + { + $this->loadDump('handy-zu-gruppe.bin'); + $this->assertCallCount(1, 1); + + $this->assertFrom('01634779878', $this->calls['startingCall'][0]); + $this->assertTo('40862', $this->calls['startingCall'][0]); + + $this->assertFrom('01634779878', $this->calls['finishedCall'][0]); + $this->assertTo('40862', $this->calls['finishedCall'][0]); + } + + protected function assertCallCount($starting, $finished) + { + $this->assertCount( + $starting, $this->calls['startingCall'], + 'Number of starting calls does not match' + ); + $this->assertCount( + $finished, $this->calls['finishedCall'], + 'Number of finished calls does not match' + ); + } + + protected function assertFrom($number, CallMonitor_Call $call) + { + $this->assertSame( + $number, $call->from, + 'Call "from" number does not match' + ); + } + + protected function assertTo($number, CallMonitor_Call $call) + { + $this->assertSame( + $number, $call->to, + 'Call "to" number does not match' + ); + } + +} + +?>