TermVectorTest   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 0%
Metric Value
wmc 1
lcom 1
cbo 1
dl 0
loc 34
ccs 0
cts 18
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B testGetVector() 0 26 1
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