Tests/PersistenceHandler/RabbitMqPersistenceHandlerTest.php
/**
     * @test
     * @testdox Tests if an exception is thrown if response size exceeds limits
     * @expectedException \Simgroep\ConcurrentSpiderBundle\InvalidContentException
     * @expectedExceptionMessage Resource size exceeds limits (1024 bytes)
     */
@test
@testdox Tests if an exception is thrown if response size exceeds limits
@expectedException \Simgroep\ConcurrentSpiderBundle\InvalidContentException
@expectedExceptionMessage Resource size exceeds limits (1024 bytes)
@test @testdox Tests if an exception is thrown if response size exceeds limits @expectedException \ Simgroep \ ConcurrentSpiderBundle \ InvalidContentException @expectedExceptionMessage Resource size exceeds limits ( 1024 bytes )
public function isExceptionThrownWhenSizeExeedsLimit()
    {
        $queue = $this
            ->getMockBuilder('Simgroep\ConcurrentSpiderBundle\Queue')
            ->disableOriginalConstructor()
            ->setMethods(['publish', '__destruct'])
            ->getMock();
        $response = $this
            ->getMockBuilder('Guzzle\Http\Message\Response')
            ->disableOriginalConstructor()
            ->setMethods(array('getBody'))
            ->getMock();
        $response
            ->expects($this->once())
            ->method('getBody')
            ->will($this->returnValue(str_repeat('A', '1025')));
        $resource = $this
            ->getMockBuilder('\VDB\Spider\Resource')
            ->disableOriginalConstructor()
            ->setMethods(array('getResponse'))
            ->getMock();
        $resource
            ->expects($this->once())
            ->method('getResponse')
            ->will($this->returnValue($response));
        $documentResolver = $this
            ->getMockBuilder('Simgroep\ConcurrentSpiderBundle\DocumentResolver\DocumentResolver')
            ->disableOriginalConstructor()
            ->getMock();
        $eventDispatcher = $this
            ->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
            ->disableOriginalConstructor()
            ->setMethods(['dispatch'])
            ->getMock();
        $persistenceHandler = new RabbitMqPersistenceHandler($queue, $documentResolver, '1KB', $eventDispatcher);
        $crawlJob = new CrawlJob('https://github.com', 'https://github.com');
        $persistenceHandler->persist($resource, $crawlJob);
    }
public function isExceptionThrownWhenSizeExeedsLimit ( ) { $ queue = $ this -> getMockBuilder ( 'Simgroep\ConcurrentSpiderBundle\Queue' ) -> disableOriginalConstructor ( ) -> setMethods ( [ 'publish' , '__destruct' ] ) -> getMock ( ) ; $ response = $ this -> getMockBuilder ( 'Guzzle\Http\Message\Response' ) -> disableOriginalConstructor ( ) -> setMethods ( array ( 'getBody' ) ) -> getMock ( ) ; $ response -> expects ( $ this -> once ( ) ) -> method ( 'getBody' ) -> will ( $ this -> returnValue ( str_repeat ( 'A' , '1025' ) ) ) ; $ resource = $ this -> getMockBuilder ( '\VDB\Spider\Resource' ) -> disableOriginalConstructor ( ) -> setMethods ( array ( 'getResponse' ) ) -> getMock ( ) ; $ resource -> expects ( $ this -> once ( ) ) -> method ( 'getResponse' ) -> will ( $ this -> returnValue ( $ response ) ) ; $ documentResolver = $ this -> getMockBuilder ( 'Simgroep\ConcurrentSpiderBundle\DocumentResolver\DocumentResolver' ) -> disableOriginalConstructor ( ) -> getMock ( ) ; $ eventDispatcher = $ this -> getMockBuilder ( 'Symfony\Component\EventDispatcher\EventDispatcher' ) -> disableOriginalConstructor ( ) -> setMethods ( [ 'dispatch' ] ) -> getMock ( ) ; $ persistenceHandler = new RabbitMqPersistenceHandler ( $ queue , $ documentResolver , '1KB' , $ eventDispatcher ) ; $ crawlJob = new CrawlJob ( 'https://github.com' , 'https://github.com' ) ; $ persistenceHandler -> persist ( $ resource , $ crawlJob ) ; }
@test
 @testdox Tests if an exception is thrown if response size exceeds limits
 @expectedException \Simgroep\ConcurrentSpiderBundle\InvalidContentException
 @expectedExceptionMessage Resource size exceeds limits (1024 bytes)
@test @testdox Tests if an exception is thrown if response size exceeds limits @expectedException \ Simgroep \ ConcurrentSpiderBundle \ InvalidContentException @expectedExceptionMessage Resource size exceeds limits ( 1024 bytes )