blob: cf89105317872c28f1fe40238d1b9abe2036a8a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
<?php
namespace SMW\Tests\Elastic\Indexer;
use SMW\Elastic\Indexer\FileIndexer;
use SMW\DIWikiPage;
use SMW\Tests\PHPUnitCompat;
/**
* @covers \SMW\Elastic\Indexer\FileIndexer
* @group semantic-mediawiki
*
* @license GNU GPL v2+
* @since 3.0
*
* @author mwjames
*/
class FileIndexerTest extends \PHPUnit_Framework_TestCase {
use PHPUnitCompat;
private $indexer;
private $logger;
protected function setUp() {
$this->indexer = $this->getMockBuilder( '\SMW\Elastic\Indexer\Indexer' )
->disableOriginalConstructor()
->getMock();
$this->logger = $this->getMockBuilder( '\Psr\Log\NullLogger' )
->disableOriginalConstructor()
->getMock();
}
public function testCanConstruct() {
$this->assertInstanceOf(
FileIndexer::class,
new FileIndexer( $this->indexer )
);
}
public function testIndex() {
$file = $this->getMockBuilder( '\File' )
->disableOriginalConstructor()
->getMock();
$file->expects( $this->once() )
->method( 'getFullURL' )
->will( $this->returnValue( 'http://example.org/Foo.txt' ) );
$ingest = $this->getMockBuilder( '\stdClass' )
->disableOriginalConstructor()
->setMethods( [ 'putPipeline' ] )
->getMock();
$ingest->expects( $this->once() )
->method( 'putPipeline' );
$client = $this->getMockBuilder( '\SMW\Elastic\Connection\Client' )
->disableOriginalConstructor()
->getMock();
$client->expects( $this->once() )
->method( 'ingest' )
->will( $this->returnValue( $ingest ) );
$this->indexer->expects( $this->atLeastOnce() )
->method( 'getConnection' )
->will( $this->returnValue( $client ) );
$instance = new FileIndexer(
$this->indexer
);
$instance->setLogger( $this->logger );
$dataItem = DIWikiPage::newFromText( __METHOD__, NS_FILE );
$dataItem->setId( 42 );
$instance->index( $dataItem, $file );
}
}
|