TermVectorTest::testGetVector()   B
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 26
Code Lines 17

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2
Metric Value
dl 0
loc 26
ccs 0
cts 18
cp 0
rs 8.8571
cc 1
eloc 17
nc 1
nop 0
crap 2
1
<?php
2
3
use SilverStripe\Elastica\ElasticaUtil;
4
5
/**
6
 * @package comments
7
 */
8
class TermVectorTest extends ElasticsearchBaseTest {
9
10
	public static $fixture_file = 'elastica/tests/lotsOfPhotos.yml';
11
12
13
	public function testGetVector() {
14
		$fp = $this->objFromFixture('FlickrPhotoTO', 'photo0023');
15
		$termVectors = $this->service->getTermVectors($fp);
16
		$terms = array_keys($termVectors);
17
		sort($terms);
18
		$expected = array('Description', 'Description.shingles', 'Description.standard',
19
			'ShutterSpeed',
20
			'TestMethod','TestMethod.shingles','TestMethod.standard',
21
			'TestMethodHTML','TestMethodHTML.shingles','TestMethodHTML.standard',
22
			'Title', 'Title.autocomplete', 'Title.shingles', 'Title.standard');
23
		$this->assertEquals($expected, $terms);
24
25
		// Now check the title terms
26
		// Original is 'Image taken from page 386 of ''The Bab Ballads, with which are included
27
		// Songs of a Savoyard ... With 350 illustrations by the author'''
28
29
30
		$expected = array(350, 386, 'author', 'bab', 'ballad', 'from', 'illustr', 'image', 'includ',
31
			'page', 'savoyard', 'song', 'taken', 'which');
32
		$this->assertEquals($expected, array_keys($termVectors['Title']['terms']));
33
34
		$expected = array(350, 386, 'author', 'bab', 'ballads', 'from', 'illustrations', 'image',
35
			'included', 'page', 'savoyard', 'songs', 'taken', 'which');
36
		$this->assertEquals($expected, array_keys($termVectors['Title.standard']['terms']));
37
38
	}
39
40
41
}
42