/** * Make sure we time out after the appropriate number of iterations with an * incomplete buffer that appears disconnected. */ public function testTimeoutOnStuckBuffer() { // An incomplete buffer $xml = <<<XML <iq from='firehoser.superfeedr.com' to='hearsayer@superfeedr.com/superfeedr' type='result' id='10'> <pubsub xmlns='http://jabber.org/protocol/pubsub'> <subscription node='http://feeds.feedburner.com/crunchgear' jid='*****@*****.**' subscription='subscribed'> <status xmlns='http://superfeedr.com/xmpp-pubsub-ext'> <http code='304'>Content not modified</http> <next_fetch>2011-06-13T06:42:37+00:00</next_fetch> <title>CrunchGear</title> XML; $xmpp = new SuperfeedrXmpp('superfeedr.com', 5222, 'user', 'pass'); $method = new \ReflectionMethod('Hearsay\\SuperfeedrBundle\\Xmpp\\SuperfeedrXmpp', 'bufferComplete'); $method->setAccessible(true); $xmpp->setMaxIncompleteIterations(2); // Run the buffer through a few times without the timeout check $this->assertFalse($method->invoke($xmpp, $xml), 'Expected buffer to be incomplete'); // No incomplete iterations $this->assertFalse($method->invoke($xmpp, $xml), 'Expected buffer to be incomplete'); // First incomplete iteration $this->assertFalse($method->invoke($xmpp, $xml), 'Expected buffer to be incomplete'); // Second incomplete iteration $this->assertFalse($method->invoke($xmpp, $xml), 'Expected buffer to be incomplete'); // Third incomplete iteration, so running count > max allowed; next should trip the timeout check $this->setExpectedException('Hearsay\\SuperfeedrBundle\\Exception\\TimeoutException'); $method->invoke($xmpp, $xml); }