/** * @dataProvider reportMessageProvider * * @param string $message */ public function testReporterInvocation($message) { $callCount = 0; $asserter = array($this, 'assertEquals'); $callback0 = function ($actual) use($message, &$callCount, $asserter) { $callCount += 1; call_user_func($asserter, $message, $actual); }; $callback1 = function ($actual) use($message, &$callCount, $asserter) { $callCount += 1; call_user_func($asserter, $message, $actual); }; $reporter0 = new ObservableMessageReporter(); $reporter0->registerReporterCallback($callback0); $reporter1 = new ObservableMessageReporter(); $reporter1->registerReporterCallback($callback1); $reporter = new ObservableMessageReporter(); $reporter->registerMessageReporter($reporter0); $reporter->registerMessageReporter($reporter1); $reporter->reportMessage($message); $this->assertEquals(2, $callCount); $reporter->reportMessage($message); $this->assertEquals(4, $callCount); }