Tests/IndexerTest.php
/**
     * @test
     * @testdox Tests if every 10 documents the index saves them.
     */
@test
@testdox Tests if every 10 documents the index saves them.
@test @testdox Tests if every 10 documents the index saves them .
public function ifEveryFiftyDocumentsAreSaved()
    {
        $solrQuery = $this
            ->getMockBuilder('Solarium\QueryType\Update\Query\Query')
            ->disableOriginalConstructor()
            ->setMethods(null)
            ->getMock();
        $solrClient = $this
            ->getMockBuilder('Solarium\Client')
            ->setMethods(['createUpdate', 'update'])
            ->getMock();
        $solrClient
            ->expects($this->any())
            ->method('createUpdate')
            ->will($this->returnValue($solrQuery));
        $mapping = [
            'id' => 'id',
            'groups' =>
                [
                    'SIM' => ['dummyKey1' => 'dummyKeySolr1'],
                    'DCTERMS' => ['dummyKey2' => 'dummyKeySolr2']
                ]
        ];
        $indexer = new Indexer($solrClient, $mapping, 50);
        for ($i = 0; $i <= 49; $i++) {
            $body = json_encode(
                [
                    'document' => [
                        'id' => rand(0, 10),
                        'title' => sha1(rand(0, 10)),
                        'tstamp' => date('Y-m-d\TH:i:s\Z'),
                        'date' => date('Y-m-d\TH:i:s\Z'),
                        'publishedDate' => date('Y-m-d\TH:i:s\Z'),
                        'content' => str_repeat(sha1(rand(0, 10)), 5),
                        'url' => 'https://www.github.com',
                        'SIM.dummyKey1' => 'dummyvalue1',
                        'DCTERMS.dummyKey2' => 'dummyvalue2'
                    ],
                    'metadata' => ['core' => 'core1']
                ]
            );
            $message = new AMQPMessage($body);
            $indexer->prepareDocument($message);
        }
    }
public function ifEveryFiftyDocumentsAreSaved ( ) { $ solrQuery = $ this -> getMockBuilder ( 'Solarium\QueryType\Update\Query\Query' ) -> disableOriginalConstructor ( ) -> setMethods ( null ) -> getMock ( ) ; $ solrClient = $ this -> getMockBuilder ( 'Solarium\Client' ) -> setMethods ( [ 'createUpdate' , 'update' ] ) -> getMock ( ) ; $ solrClient -> expects ( $ this -> any ( ) ) -> method ( 'createUpdate' ) -> will ( $ this -> returnValue ( $ solrQuery ) ) ; $ mapping = [ 'id' => 'id' , 'groups' => [ 'SIM' => [ 'dummyKey1' => 'dummyKeySolr1' ] , 'DCTERMS' => [ 'dummyKey2' => 'dummyKeySolr2' ] ] ] ; $ indexer = new Indexer ( $ solrClient , $ mapping , 50 ) ; for ( $ i = 0 ; $ i <= 49 ; $ i ++ ) { $ body = json_encode ( [ 'document' => [ 'id' => rand ( 0 , 10 ) , 'title' => sha1 ( rand ( 0 , 10 ) ) , 'tstamp' => date ( 'Y-m-d\TH:i:s\Z' ) , 'date' => date ( 'Y-m-d\TH:i:s\Z' ) , 'publishedDate' => date ( 'Y-m-d\TH:i:s\Z' ) , 'content' => str_repeat ( sha1 ( rand ( 0 , 10 ) ) , 5 ) , 'url' => 'https://www.github.com' , 'SIM.dummyKey1' => 'dummyvalue1' , 'DCTERMS.dummyKey2' => 'dummyvalue2' ] , 'metadata' => [ 'core' => 'core1' ] ] ) ; $ message = new AMQPMessage ( $ body ) ; $ indexer -> prepareDocument ( $ message ) ; } }
@test
 @testdox Tests if every 10 documents the index saves them.
@test @testdox Tests if every 10 documents the index saves them .