/** * @dataProvider getData */ public function testRegisterCallbacksMethod($data) { $called1 = 0; $called2 = 0; $expectedItems = 25; $expectedItems2 = 240; $xmlParser = new Parser(); $callback = function () use(&$called1) { $called1++; }; $callback2 = function () use(&$called2) { $called2++; }; $xmlParser->registerCallbacks(array(array('/rss/channel/item', $callback), array('/rss/channel/item/category', $callback2))); $xmlParser->parse($data); $this->assertSame($expectedItems, $called1); $this->assertSame($expectedItems2, $called2); $this->setExpectedException('Exception', 'must be an array of 2'); $xmlParser->registerCallbacks(array(array('/rss/channel/item'))); }