Completed
Push — dev2 ( 1a1275...6bca8c )
by Gordon
03:02
created
tests/TranslatableUnitTest.php 2 patches
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -233,6 +233,9 @@
 block discarded – undo
233 233
 
234 234
 
235 235
 
236
+	/**
237
+	 * @param PaginatedList $paginated
238
+	 */
236 239
 	private function makeCode($paginated) {
237 240
 		$results = $paginated->getList()->toArray();
238 241
 		$ctr = 0;
Please login to merge, or discard this patch.
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -42,21 +42,21 @@  discard block
 block discarded – undo
42 42
 		$paginated = $es->search($query, $fields);
43 43
 		$ctr = 0;
44 44
 
45
-		foreach ($paginated->getList()->toArray() as $result) {
45
+		foreach($paginated->getList()->toArray() as $result) {
46 46
 			$ctr++;
47 47
 
48
-			foreach ($result->SearchHighlightsByField->Description->getIterator() as $highlight) {
48
+			foreach($result->SearchHighlightsByField->Description->getIterator() as $highlight) {
49 49
 				$snippet = $highlight->Snippet;
50 50
 				$snippet = strtolower($snippet);
51 51
 				$wordFound = false;
52 52
 				$lcquery = explode(' ', strtolower($query));
53
-				foreach ($lcquery as $part) {
54
-					$bracketed = '<strong class="hl">'.$part.'</strong>';
55
-					if (strpos($snippet, $bracketed) > 0) {
53
+				foreach($lcquery as $part) {
54
+					$bracketed = '<strong class="hl">' . $part . '</strong>';
55
+					if(strpos($snippet, $bracketed) > 0) {
56 56
 						$wordFound = true;
57 57
 					}
58 58
 				}
59
-				$this->assertTrue($wordFound,'Highlight should have been found');
59
+				$this->assertTrue($wordFound, 'Highlight should have been found');
60 60
 			}
61 61
 		}
62 62
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 		$query = 'Lond';
70 70
 		$results = $es->autocomplete_search($query, 'Title');
71 71
 		$this->assertEquals(7, $results->getTotalItems());
72
-		foreach ($results->toArray() as $result) {
72
+		foreach($results->toArray() as $result) {
73 73
 			$this->assertTrue(strpos($result->Title, $query) > 0);
74 74
 		}
75 75
 	}
@@ -89,11 +89,11 @@  discard block
 block discarded – undo
89 89
 		$es->setLocale($locale);
90 90
 		$es->setClasses('FlickrPhotoTO');
91 91
 
92
-		$fields = array('Description.standard' => 1,'Title.standard' => 1);
92
+		$fields = array('Description.standard' => 1, 'Title.standard' => 1);
93 93
 		$results = $es->moreLikeThis($fp, $fields, true);
94 94
 
95 95
 		echo "RESULTS:\n";
96
-		foreach ($results as $result) {
96
+		foreach($results as $result) {
97 97
 			echo "-\t{$result->Title}\n";
98 98
 		}
99 99
 
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
 		$expected = array('texas');
111 111
 		$this->assertEquals($expected, $terms['Title.standard']);
112 112
 
113
-		$expected = array('new', 'see','photographs', 'information','resolution', 'company', 'view',
113
+		$expected = array('new', 'see', 'photographs', 'information', 'resolution', 'company', 'view',
114 114
 			'high', 'collection', 'pacific', 'orleans', 'degolyer', 'southern', 'everett',
115 115
 			'railroad', 'texas');
116 116
 
@@ -143,8 +143,8 @@  discard block
 block discarded – undo
143 143
 		$es->setClasses('FlickrPhotoTO');
144 144
 		$fields = array('Title.standard' => 1, 'Description.standard' => 1);
145 145
 		$paginated = $es->moreLikeThis($fp, $fields, true);
146
-		foreach ($paginated->getList() as $result) {
147
-			echo $result->ID. ' : '.$result->Title."\n";
146
+		foreach($paginated->getList() as $result) {
147
+			echo $result->ID . ' : ' . $result->Title . "\n";
148 148
 		}
149 149
 		$this->assertEquals(32, $paginated->getTotalItems());
150 150
 		$results = $paginated->getList()->toArray();
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
 		//Check that the number of indexing requests has increased by 2
180 180
 		$deltaReqs = $this->service->getIndexingRequestCtr() - $reqs;
181 181
 		//One call is made for each of Page and FlickrPhotoTO
182
-		$this->assertEquals(2,$deltaReqs);
182
+		$this->assertEquals(2, $deltaReqs);
183 183
 
184 184
 		// default installed pages plus 100 FlickrPhotoTOs
185 185
 		$this->checkNumberOfIndexedDocuments(103);
@@ -194,8 +194,8 @@  discard block
 block discarded – undo
194 194
 		$es->setClasses('FlickrPhotoTO');
195 195
 		$fields = array('Title.standard' => 1, 'Description.standard' => 1);
196 196
 		$paginated = $es->moreLikeThis($fp, $fields, true);
197
-		foreach ($paginated->getList() as $result) {
198
-			echo $result->ID. ' : '.$result->Title."\n";
197
+		foreach($paginated->getList() as $result) {
198
+			echo $result->ID . ' : ' . $result->Title . "\n";
199 199
 		}
200 200
 		$this->assertEquals(14, $paginated->getTotalItems());
201 201
 		$results = $paginated->getList()->toArray();
@@ -236,9 +236,9 @@  discard block
 block discarded – undo
236 236
 	private function makeCode($paginated) {
237 237
 		$results = $paginated->getList()->toArray();
238 238
 		$ctr = 0;
239
-		echo '$result = $paginated->getList()->toArray();'."\n";
240
-		foreach ($results as $result) {
241
-			echo '$this->assertEquals("'.$result->Title.'", $results['.$ctr.']->Title);'."\n";
239
+		echo '$result = $paginated->getList()->toArray();' . "\n";
240
+		foreach($results as $result) {
241
+			echo '$this->assertEquals("' . $result->Title . '", $results[' . $ctr . ']->Title);' . "\n";
242 242
 			$ctr++;
243 243
 		}
244 244
 	}
Please login to merge, or discard this patch.
code/SearchableClass.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -29,20 +29,20 @@  discard block
 block discarded – undo
29 29
 		$config->removeComponent($config->getComponentByType('GridFieldDeleteAction'));
30 30
 
31 31
 		$config->getComponentByType('GridFieldDataColumns')->setDisplayFields(array(
32
-            'Name' => 'Name',
33
-            'Weight' => 'Weighting',
34
-            'Searchable' => 'Search this field?'
35
-        ));
32
+			'Name' => 'Name',
33
+			'Weight' => 'Weighting',
34
+			'Searchable' => 'Search this field?'
35
+		));
36 36
 
37 37
 
38
-        $gridField = new GridField(
39
-            'SearchableField', // Field name
40
-            'Field Name', // Field title
41
-            SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'),
42
-            $config
43
-        );
38
+		$gridField = new GridField(
39
+			'SearchableField', // Field name
40
+			'Field Name', // Field title
41
+			SearchableField::get()->filter('SearchableClassID', $this->ID)->sort('Name'),
42
+			$config
43
+		);
44 44
 
45
-        $fields->addFieldToTab('Root.Main', $gridField);
45
+		$fields->addFieldToTab('Root.Main', $gridField);
46 46
 
47 47
 		/*
48 48
 	    $fields = new FieldList();
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
 
52 52
         */
53
-	    return $fields;
53
+		return $fields;
54 54
 	}
55 55
 
56 56
 
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@
 block discarded – undo
15 15
 
16 16
 		$fields = new FieldList();
17 17
 
18
-		$fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) );
19
-		$mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) );
18
+		$fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
19
+		$mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
20 20
 
21
-		$fields->addFieldToTab( 'Root.Main',  $nf = new TextField( 'Name', 'Name') );
21
+		$fields->addFieldToTab('Root.Main', $nf = new TextField('Name', 'Name'));
22 22
 		$nf->setReadOnly(true);
23 23
 		$nf->setDisabled(true);
24 24
 
Please login to merge, or discard this patch.
code/SearchableField.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,10 +24,10 @@
 block discarded – undo
24 24
 
25 25
 	function getCMSFields() {
26 26
 		$fields = new FieldList();
27
-		$fields->push( new TabSet( "Root", $mainTab = new Tab( "Main" ) ) );
28
-		$mainTab->setTitle( _t( 'SiteTree.TABMAIN', "Main" ) );
29
-		$fields->addFieldToTab( 'Root.Main',  $cf = new TextField( 'ClazzName', 'Class sourced from') );
30
-		$fields->addFieldToTab( 'Root.Main',  $nf = new TextField( 'Name', 'Name') );
27
+		$fields->push(new TabSet("Root", $mainTab = new Tab("Main")));
28
+		$mainTab->setTitle(_t('SiteTree.TABMAIN', "Main"));
29
+		$fields->addFieldToTab('Root.Main', $cf = new TextField('ClazzName', 'Class sourced from'));
30
+		$fields->addFieldToTab('Root.Main', $nf = new TextField('Name', 'Name'));
31 31
 		$cf->setDisabled(true);
32 32
 		$nf->setDisabled(true);
33 33
 		$cf->setReadOnly(true);
Please login to merge, or discard this patch.
code/ElasticaUtil.php 2 patches
Indentation   +38 added lines, -38 removed lines patch added patch discarded remove patch
@@ -92,26 +92,26 @@  discard block
 block discarded – undo
92 92
 					//Need to check capitalisation of terms suggested that are different
93 93
 
94 94
 					$chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8");
95
-    				if (mb_strtolower($chr, "UTF-8") != $chr) {
96
-    					$upperLowercaseWord = $lowercaseWord;
97
-    					$upperLowercaseWord[0] = $chr;
95
+					if (mb_strtolower($chr, "UTF-8") != $chr) {
96
+						$upperLowercaseWord = $lowercaseWord;
97
+						$upperLowercaseWord[0] = $chr;
98 98
 
99
-    					//$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted);
100
-    					$withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted);
99
+						//$possiblyUppercaseHighlighted = str_replace($lowercaseWord, $possiblyUppercase, $possiblyUppercaseHighlighted);
100
+						$withHighlights = str_replace($lowercaseWord, $upperLowercaseWord, $possiblyUppercaseHighlighted);
101 101
 
102
-    					$lowercaseWord[0] = $chr;
102
+						$lowercaseWord[0] = $chr;
103 103
 
104
-    					//str_replace(search, replace, subject)
104
+						//str_replace(search, replace, subject)
105 105
 
106
-    					array_push($plain, $lowercaseWord);
107
-    					array_push($highlighted, $withHighlights);
108
-    				} else {
109
-    					//No need to capitalise, so add suggested word
110
-    					array_push($plain, $lowercaseWord);
106
+						array_push($plain, $lowercaseWord);
107
+						array_push($highlighted, $withHighlights);
108
+					} else {
109
+						//No need to capitalise, so add suggested word
110
+						array_push($plain, $lowercaseWord);
111 111
 
112
-    					//No need to capitalise, so add suggested highlighted word
113
-    					array_push($highlighted, $possiblyUppercaseHighlighted);
114
-    				}
112
+						//No need to capitalise, so add suggested highlighted word
113
+						array_push($highlighted, $possiblyUppercaseHighlighted);
114
+					}
115 115
 				}
116 116
 			}
117 117
 
@@ -144,37 +144,37 @@  discard block
 block discarded – undo
144 144
 
145 145
 		$explanation = explode('-ConstantScore', $explanation)[0];
146 146
 
147
-        $bracketPos = strpos($explanation, ')~');
147
+		$bracketPos = strpos($explanation, ')~');
148 148
 
149
-        if (substr($explanation, 0,2) == '((') {
150
-        	$explanation = substr($explanation, 2, $bracketPos-2);
151
-        } elseif (substr($explanation, 0,1) == '(') {
152
-        	$explanation = substr($explanation, 1, $bracketPos-2);
153
-        }
149
+		if (substr($explanation, 0,2) == '((') {
150
+			$explanation = substr($explanation, 2, $bracketPos-2);
151
+		} elseif (substr($explanation, 0,1) == '(') {
152
+			$explanation = substr($explanation, 1, $bracketPos-2);
153
+		}
154 154
 
155
-       	$terms = array();
155
+	   	$terms = array();
156 156
 
157
-        //Field name(s) => terms
158
-        $splits = explode(' ', $explanation);
157
+		//Field name(s) => terms
158
+		$splits = explode(' ', $explanation);
159 159
 
160
-        foreach ($splits as $fieldAndTerm) {
161
-        	$splits = explode(':', $fieldAndTerm);
160
+		foreach ($splits as $fieldAndTerm) {
161
+			$splits = explode(':', $fieldAndTerm);
162 162
 
163
-        	// This is the no terms case
164
-        	if (sizeof($splits) < 2) {
165
-        		break;
166
-        	}
163
+			// This is the no terms case
164
+			if (sizeof($splits) < 2) {
165
+				break;
166
+			}
167 167
 
168
-        	$fieldname = $splits[0];
169
-        	$term = $splits[1];
168
+			$fieldname = $splits[0];
169
+			$term = $splits[1];
170 170
 
171
-        	if (!isset($terms[$fieldname])) {
172
-        		$terms[$fieldname] = array();
173
-        	}
171
+			if (!isset($terms[$fieldname])) {
172
+				$terms[$fieldname] = array();
173
+			}
174 174
 
175
-        	array_push($terms[$fieldname], $term);
176
-        }
175
+			array_push($terms[$fieldname], $term);
176
+		}
177 177
 
178
-        return $terms;
178
+		return $terms;
179 179
 	}
180 180
 }
Please login to merge, or discard this patch.
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
 	 * @var string $content Text to display when in command line mode
24 24
 	 */
25 25
 	public static function message($content) {
26
-		if (\Director::is_cli()) {
26
+		if(\Director::is_cli()) {
27 27
 			echo "$content\n";
28 28
 		}
29 29
 	}
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
 
50 50
 		$resultArray = null;
51 51
 
52
-		if (sizeof($options) > 0) {
52
+		if(sizeof($options) > 0) {
53 53
 			//take the first suggestion
54 54
 			$suggestedPhrase = $options[0]['text'];
55 55
 			$suggestedPhraseHighlighted = $options[0]['highlighted'];
@@ -58,10 +58,10 @@  discard block
 block discarded – undo
58 58
 			$originalParts = explode(' ', $originalQuery);
59 59
 			$suggestedParts = explode(' ', $suggestedPhrase);
60 60
 
61
-			$markedHighlightedParts = ' '.$suggestedPhraseHighlighted.' ';
62
-			$markedHighlightedParts = str_replace(' '.$preTags, ' '.self::$pre_marker, $markedHighlightedParts);
61
+			$markedHighlightedParts = ' ' . $suggestedPhraseHighlighted . ' ';
62
+			$markedHighlightedParts = str_replace(' ' . $preTags, ' ' . self::$pre_marker, $markedHighlightedParts);
63 63
 
64
-			$markedHighlightedParts = str_replace($postTags.' ', self::$post_marker, $markedHighlightedParts);
64
+			$markedHighlightedParts = str_replace($postTags . ' ', self::$post_marker, $markedHighlightedParts);
65 65
 
66 66
 			$markedHighlightedParts = trim($markedHighlightedParts);
67 67
 			$markedHighlightedParts = trim($markedHighlightedParts);
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 			$lowerToUpper = array();
73 73
 			$lowerToHighlighted = array();
74 74
 			$ctr = 0;
75
-			foreach ($suggestedParts as $lowercaseWord) {
75
+			foreach($suggestedParts as $lowercaseWord) {
76 76
 				$lowerToUpper[$lowercaseWord] = $originalParts[$ctr];
77 77
 				$lowerToHighlighted[$lowercaseWord] = $highlightedParts[$ctr];
78 78
 				$ctr++;
@@ -80,19 +80,19 @@  discard block
 block discarded – undo
80 80
 
81 81
 			$plain = array();
82 82
 			$highlighted = array();
83
-			foreach ($suggestedParts as $lowercaseWord) {
83
+			foreach($suggestedParts as $lowercaseWord) {
84 84
 				$possiblyUppercase = $lowerToUpper[$lowercaseWord];
85 85
 				$possiblyUppercaseHighlighted = $lowerToHighlighted[$lowercaseWord];
86 86
 
87 87
 				//If the terms are identical other than case, e.g. new => New, then simply swap
88
-				if (strtolower($possiblyUppercase) == $lowercaseWord) {
88
+				if(strtolower($possiblyUppercase) == $lowercaseWord) {
89 89
 					array_push($plain, $possiblyUppercase);
90 90
 					array_push($highlighted, $possiblyUppercase);
91 91
 				} else {
92 92
 					//Need to check capitalisation of terms suggested that are different
93 93
 
94
-					$chr = mb_substr ($possiblyUppercase, 0, 1, "UTF-8");
95
-    				if (mb_strtolower($chr, "UTF-8") != $chr) {
94
+					$chr = mb_substr($possiblyUppercase, 0, 1, "UTF-8");
95
+    				if(mb_strtolower($chr, "UTF-8") != $chr) {
96 96
     					$upperLowercaseWord = $lowercaseWord;
97 97
     					$upperLowercaseWord[0] = $chr;
98 98
 
@@ -115,9 +115,9 @@  discard block
 block discarded – undo
115 115
 				}
116 116
 			}
117 117
 
118
-			$highlighted = ' '.implode(' ', $highlighted).' ';
119
-			$highlighted = str_replace(self::$pre_marker, ' '.$preTags, $highlighted);
120
-			$highlighted = str_replace(self::$post_marker, $postTags.' ', $highlighted);
118
+			$highlighted = ' ' . implode(' ', $highlighted) . ' ';
119
+			$highlighted = str_replace(self::$pre_marker, ' ' . $preTags, $highlighted);
120
+			$highlighted = str_replace(self::$post_marker, $postTags . ' ', $highlighted);
121 121
 
122 122
 			$resultArray['suggestedQuery'] = implode(' ', $plain);
123 123
 			$resultArray['suggestedQueryHighlighted'] = trim($highlighted);
@@ -146,10 +146,10 @@  discard block
 block discarded – undo
146 146
 
147 147
         $bracketPos = strpos($explanation, ')~');
148 148
 
149
-        if (substr($explanation, 0,2) == '((') {
150
-        	$explanation = substr($explanation, 2, $bracketPos-2);
151
-        } elseif (substr($explanation, 0,1) == '(') {
152
-        	$explanation = substr($explanation, 1, $bracketPos-2);
149
+        if(substr($explanation, 0, 2) == '((') {
150
+        	$explanation = substr($explanation, 2, $bracketPos - 2);
151
+        } elseif(substr($explanation, 0, 1) == '(') {
152
+        	$explanation = substr($explanation, 1, $bracketPos - 2);
153 153
         }
154 154
 
155 155
        	$terms = array();
@@ -157,18 +157,18 @@  discard block
 block discarded – undo
157 157
         //Field name(s) => terms
158 158
         $splits = explode(' ', $explanation);
159 159
 
160
-        foreach ($splits as $fieldAndTerm) {
160
+        foreach($splits as $fieldAndTerm) {
161 161
         	$splits = explode(':', $fieldAndTerm);
162 162
 
163 163
         	// This is the no terms case
164
-        	if (sizeof($splits) < 2) {
164
+        	if(sizeof($splits) < 2) {
165 165
         		break;
166 166
         	}
167 167
 
168 168
         	$fieldname = $splits[0];
169 169
         	$term = $splits[1];
170 170
 
171
-        	if (!isset($terms[$fieldname])) {
171
+        	if(!isset($terms[$fieldname])) {
172 172
         		$terms[$fieldname] = array();
173 173
         	}
174 174
 
Please login to merge, or discard this patch.
tests/SearchableTest.php 3 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -553,10 +553,10 @@
 block discarded – undo
553 553
 		print_r($sr);
554 554
 
555 555
 
556
-    	//$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs');
556
+		//$sr2 = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs');
557 557
 
558
-    	// MUST REMOVE FIRST.  Otherwise append and the erroroneus value above still exists
559
-    	$config->remove('FlickrPhotoTO', 'searchable_relationships');
558
+		// MUST REMOVE FIRST.  Otherwise append and the erroroneus value above still exists
559
+		$config->remove('FlickrPhotoTO', 'searchable_relationships');
560 560
 		$config->update('FlickrPhotoTO' ,'searchable_relationships', $sr);
561 561
 	}
562 562
 
Please login to merge, or discard this patch.
Doc Comments   +3 added lines patch added patch discarded remove patch
@@ -479,6 +479,9 @@
 block discarded – undo
479 479
 	}
480 480
 
481 481
 
482
+	/**
483
+	 * @param string $query
484
+	 */
482 485
 	private function getResultsFor($query, $pageLength = 10, $fields = array('Title' => 1, 'Description' => 1)) {
483 486
 		$es = new ElasticSearcher();
484 487
 		$es->setStart(0);
Please login to merge, or discard this patch.
Spacing   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
13 13
 	public function setUp() {
14 14
 		// this needs to be called in order to create the list of searchable
15 15
 		// classes and fields that are available.  Simulates part of a build
16
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
16
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
17 17
 			'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO');
18 18
 		$this->requireDefaultRecordsFrom = $classes;
19 19
 
@@ -188,20 +188,20 @@  discard block
 block discarded – undo
188 188
 
189 189
 
190 190
 		// check strings
191
-		$shouldBeString = array('Title','Description');
192
-		$shouldBeInt = array('ISO','FlickrID','FocalLength35mm');
191
+		$shouldBeString = array('Title', 'Description');
192
+		$shouldBeInt = array('ISO', 'FlickrID', 'FocalLength35mm');
193 193
 		$shouldBeBoolean = array('IsInSiteTree');
194 194
 		$shouldBeDouble = array('Aperture');
195 195
 		$shouldBeDateTime = array('TakenAt');
196 196
 		$shouldBeDate = array('FirstViewed');
197 197
 
198 198
 		// tokens are strings that have analyzer 'not_analyzed', namely the string is indexed as is
199
-		$shouldBeTokens = array('ShutterSpeed','Link');
199
+		$shouldBeTokens = array('ShutterSpeed', 'Link');
200 200
 
201 201
 
202 202
 		// check strings
203 203
 		$expectedStandardArray = array('type' => 'string', 'analyzer' => 'unstemmed', 'term_vector' => 'yes');
204
-		foreach ($shouldBeString as $fieldName) {
204
+		foreach($shouldBeString as $fieldName) {
205 205
 			$fieldProperties = $properties[$fieldName];
206 206
 
207 207
 			$type = $fieldProperties['type'];
@@ -213,60 +213,60 @@  discard block
 block discarded – undo
213 213
 
214 214
 			// check for unstemmed analaysis
215 215
 
216
-			$this->assertEquals($expectedStandardArray,$fieldProperties['fields']['standard']);
216
+			$this->assertEquals($expectedStandardArray, $fieldProperties['fields']['standard']);
217 217
 
218 218
 			// check for only 3 entries
219 219
 			$this->assertEquals(4, sizeof(array_keys($fieldProperties)));
220 220
 		}
221 221
 
222 222
 		// check ints
223
-		foreach ($shouldBeInt as $fieldName) {
223
+		foreach($shouldBeInt as $fieldName) {
224 224
 			$fieldProperties = $properties[$fieldName];
225 225
 			$type = $fieldProperties['type'];
226 226
 			$this->assertEquals(1, sizeof(array_keys($fieldProperties)));
227
-			$this->assertEquals('integer',$type);
227
+			$this->assertEquals('integer', $type);
228 228
 		}
229 229
 
230 230
 
231 231
 		// check doubles
232
-		foreach ($shouldBeDouble as $fieldName) {
232
+		foreach($shouldBeDouble as $fieldName) {
233 233
 			$fieldProperties = $properties[$fieldName];
234 234
 			$type = $fieldProperties['type'];
235 235
 			$this->assertEquals(1, sizeof(array_keys($fieldProperties)));
236
-			$this->assertEquals('double',$type);
236
+			$this->assertEquals('double', $type);
237 237
 		}
238 238
 
239 239
 		// check boolean
240
-		foreach ($shouldBeBoolean as $fieldName) {
240
+		foreach($shouldBeBoolean as $fieldName) {
241 241
 			$fieldProperties = $properties[$fieldName];
242 242
 			$type = $fieldProperties['type'];
243 243
 			$this->assertEquals(1, sizeof(array_keys($fieldProperties)));
244
-			$this->assertEquals('boolean',$type);
244
+			$this->assertEquals('boolean', $type);
245 245
 		}
246 246
 
247 247
 
248
-		foreach ($shouldBeDate as $fieldName) {
248
+		foreach($shouldBeDate as $fieldName) {
249 249
 			$fieldProperties = $properties[$fieldName];
250 250
 			$type = $fieldProperties['type'];
251 251
 			$this->assertEquals(2, sizeof(array_keys($fieldProperties)));
252
-			$this->assertEquals('date',$type);
252
+			$this->assertEquals('date', $type);
253 253
 			$this->assertEquals('y-M-d', $fieldProperties['format']);
254 254
 		}
255 255
 
256 256
 
257 257
 
258 258
 		// check date time, stored in Elasticsearch as a date with a different format than above
259
-		foreach ($shouldBeDateTime as $fieldName) {
259
+		foreach($shouldBeDateTime as $fieldName) {
260 260
 			$fieldProperties = $properties[$fieldName];
261 261
 			$type = $fieldProperties['type'];
262 262
 			$this->assertEquals(2, sizeof(array_keys($fieldProperties)));
263
-			$this->assertEquals('date',$type);
263
+			$this->assertEquals('date', $type);
264 264
 			$this->assertEquals('y-M-d H:m:s', $fieldProperties['format']);
265 265
 		}
266 266
 
267 267
 		//check shutter speed is tokenized, ie not analyzed - for aggregation purposes
268 268
 		//
269
-		foreach ($shouldBeTokens as $fieldName) {
269
+		foreach($shouldBeTokens as $fieldName) {
270 270
 			$fieldProperties = $properties[$fieldName];
271 271
 			$type = $fieldProperties['type'];
272 272
 			$this->assertEquals('string', $type);
@@ -299,7 +299,7 @@  discard block
 block discarded – undo
299 299
 		$doc = $flickrPhoto->getElasticaDocument()->getData();
300 300
 
301 301
 		$expected = array();
302
-		$expected['Title'] = 'Bangkok' ;
302
+		$expected['Title'] = 'Bangkok';
303 303
 		$expected['FlickrID'] = '1234567';
304 304
 		$expected['Description'] = 'Test photograph';
305 305
 		$expected['TakenAt'] = '2011-07-04 20:36:00';
@@ -333,7 +333,7 @@  discard block
 block discarded – undo
333 333
 		$resultList = $this->getResultsFor('Bangkok');
334 334
 
335 335
 		// there is only one result.  Note lack of a 'first' method
336
-		foreach ($resultList->getIterator() as $fp) {
336
+		foreach($resultList->getIterator() as $fp) {
337 337
 			//This is an Elastica\Result object
338 338
 			$elasticaResult = $fp->getElasticaResult();
339 339
 
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 		$page = $this->objFromFixture('SiteTree', 'sitetree001');
389 389
 		$page->doUnpublish();
390 390
 
391
-		$this->checkNumberOfIndexedDocuments($nDocsAtStart-1);
391
+		$this->checkNumberOfIndexedDocuments($nDocsAtStart - 1);
392 392
 
393 393
 		$page->doPublish();
394 394
 		$this->checkNumberOfIndexedDocuments($nDocsAtStart);
@@ -481,7 +481,7 @@  discard block
 block discarded – undo
481 481
 		$flickrPhoto = $this->objFromFixture('FlickrPhotoTO', 'photo0001');
482 482
 		$fields = $flickrPhoto->getCMSFields();
483 483
 
484
-		$tab = $this->checkTabExists($fields,'ElasticaTermsset');
484
+		$tab = $this->checkTabExists($fields, 'ElasticaTermsset');
485 485
 	}
486 486
 
487 487
 
@@ -497,7 +497,7 @@  discard block
 block discarded – undo
497 497
 			$this->assertEquals('The field $searchable_fields must be set for the class FlickrPhotoTO', $e->getMessage());
498 498
 		}
499 499
 
500
-		$config->update('FlickrPhotoTO' ,'searchable_fields', $sf);
500
+		$config->update('FlickrPhotoTO', 'searchable_fields', $sf);
501 501
 	}
502 502
 
503 503
 
@@ -513,7 +513,7 @@  discard block
 block discarded – undo
513 513
 			$this->assertEquals('The field $searchable_fields must be set for the class FlickrTagTO', $e->getMessage());
514 514
 		}
515 515
 
516
-		$config->update('FlickrTagTO' ,'searchable_fields', $sf);
516
+		$config->update('FlickrTagTO', 'searchable_fields', $sf);
517 517
 
518 518
 	}
519 519
 
@@ -530,7 +530,7 @@  discard block
 block discarded – undo
530 530
 			$this->assertEquals('The field $searchable_fields must be set for the class FlickrAuthorTO', $e->getMessage());
531 531
 		}
532 532
 
533
-		$config->update('FlickrAuthorTO' ,'searchable_fields', $sf);
533
+		$config->update('FlickrAuthorTO', 'searchable_fields', $sf);
534 534
 
535 535
 	}
536 536
 
@@ -539,7 +539,7 @@  discard block
 block discarded – undo
539 539
 		$config = Config::inst();
540 540
 		$sr = $config->get('FlickrPhotoTO', 'searchable_relationships');
541 541
 		$config->remove('FlickrPhotoTO', 'searchable_relationships');
542
-		$config->update('FlickrPhotoTO', 'searchable_relationships',array('thisMethodDoesNotExist'));
542
+		$config->update('FlickrPhotoTO', 'searchable_relationships', array('thisMethodDoesNotExist'));
543 543
 		$fp = Injector::inst()->create('FlickrPhotoTO');
544 544
 		try {
545 545
 			$fields = $fp->getAllSearchableFields();
@@ -557,7 +557,7 @@  discard block
 block discarded – undo
557 557
 
558 558
     	// MUST REMOVE FIRST.  Otherwise append and the erroroneus value above still exists
559 559
     	$config->remove('FlickrPhotoTO', 'searchable_relationships');
560
-		$config->update('FlickrPhotoTO' ,'searchable_relationships', $sr);
560
+		$config->update('FlickrPhotoTO', 'searchable_relationships', $sr);
561 561
 	}
562 562
 
563 563
 
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
 
670 670
 		$photographer->write();
671 671
 
672
-		$flickrPhoto->PhotographerID = $photographer->ID;;
672
+		$flickrPhoto->PhotographerID = $photographer->ID; ;
673 673
 		$flickrPhoto->write();
674
-		echo 'ID='.$flickrPhoto->PhotographerID;
674
+		echo 'ID=' . $flickrPhoto->PhotographerID;
675 675
 		$a = $flickrPhoto->getFieldValuesAsArray();
676 676
 
677 677
 		print_r($a);
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 
719 719
 
720 720
 		$flickrPhoto->write();
721
-		echo 'ID='.$flickrPhoto->PhotographerID;
721
+		echo 'ID=' . $flickrPhoto->PhotographerID;
722 722
 		$a = $flickrPhoto->getFieldValuesAsArray();
723 723
 
724 724
 		print_r($a);
@@ -761,20 +761,20 @@  discard block
 block discarded – undo
761 761
 
762 762
 		$tabset = $fields->findOrMakeTab('Root.ElasticaTerms');
763 763
 		$tabNames = array();
764
-		foreach ($tabset->Tabs() as $tab) {
764
+		foreach($tabset->Tabs() as $tab) {
765 765
 			$tabFields = array();
766
-			foreach ($tab->FieldList() as $field) {
766
+			foreach($tab->FieldList() as $field) {
767 767
 				array_push($tabFields, $field->getName());
768 768
 			}
769
-			$expectedName = 'TermsFor'.$tab->getName();;
769
+			$expectedName = 'TermsFor' . $tab->getName(); ;
770 770
 			$expected = array($expectedName);
771 771
 			$this->assertEquals($expected, $tabFields);
772 772
 			array_push($tabNames, $tab->getName());
773 773
 		}
774
-		$expected = array('Description','Description_shingles','Description_standard',
775
-			'ShutterSpeed',  'TestMethod', 'TestMethod_shingles', 'TestMethod_standard',
774
+		$expected = array('Description', 'Description_shingles', 'Description_standard',
775
+			'ShutterSpeed', 'TestMethod', 'TestMethod_shingles', 'TestMethod_standard',
776 776
 			'TestMethodHTML', 'TestMethodHTML_shingles', 'TestMethodHTML_standard',
777
-			'Title','Title_autocomplete','Title_shingles','Title_standard');
777
+			'Title', 'Title_autocomplete', 'Title_shingles', 'Title_standard');
778 778
 
779 779
 		$this->assertEquals($expected, $tabNames);
780 780
 	}
@@ -793,18 +793,18 @@  discard block
 block discarded – undo
793 793
 
794 794
 		$tabset = $fields->findOrMakeTab('Root.ElasticaTerms');
795 795
 		$tabNames = array();
796
-		foreach ($tabset->Tabs() as $tab) {
796
+		foreach($tabset->Tabs() as $tab) {
797 797
 			$tabFields = array();
798
-			foreach ($tab->FieldList() as $field) {
798
+			foreach($tab->FieldList() as $field) {
799 799
 				array_push($tabFields, $field->getName());
800 800
 			}
801
-			$expectedName = 'TermsFor'.$tab->getName();;
801
+			$expectedName = 'TermsFor' . $tab->getName(); ;
802 802
 			$expected = array($expectedName);
803 803
 			$this->assertEquals($expected, $tabFields);
804 804
 			array_push($tabNames, $tab->getName());
805 805
 		}
806 806
 		$expected = array(
807
-			'Content','Content_standard','Link','Title','Title_autocomplete','Title_shingles',
807
+			'Content', 'Content_standard', 'Link', 'Title', 'Title_autocomplete', 'Title_shingles',
808 808
 			'Title_standard');
809 809
 		$this->generateAssertionsFromArray1D($tabNames);
810 810
 		$this->assertEquals($expected, $tabNames);
Please login to merge, or discard this patch.
tests/AutoCompleteOptionTest.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -31,13 +31,13 @@
 block discarded – undo
31 31
 	public function testRequireDefaultRecords() {
32 32
 		$this->AutoCompleteOption->requireDefaultRecords();
33 33
 
34
-		$similar = AutoCompleteOption::get()->filter('Name','Similar')->first();
34
+		$similar = AutoCompleteOption::get()->filter('Name', 'Similar')->first();
35 35
 		$this->assertEquals(1, $similar->ID);
36 36
 
37
-		$search = AutoCompleteOption::get()->filter('Name','Search')->first();
37
+		$search = AutoCompleteOption::get()->filter('Name', 'Search')->first();
38 38
 		$this->assertEquals(2, $search->ID);
39 39
 
40
-		$goto = AutoCompleteOption::get()->filter('Name','GoToRecord')->first();
40
+		$goto = AutoCompleteOption::get()->filter('Name', 'GoToRecord')->first();
41 41
 		$this->assertEquals(3, $goto->ID);
42 42
 
43 43
 	}
Please login to merge, or discard this patch.
tests/SearchableClassTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,7 @@
 block discarded – undo
14 14
 
15 15
 		$fields = $sc->getCMSFields();
16 16
 
17
-		$tab = $this->checkTabExists($fields,'Main');
17
+		$tab = $this->checkTabExists($fields, 'Main');
18 18
 
19 19
 		//Check fields
20 20
 		$nf = $this->checkFieldExists($tab, 'Name');
Please login to merge, or discard this patch.
tests/IndexSettingsTest.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -9,7 +9,7 @@
 block discarded – undo
9 9
 	public function setUp() {
10 10
 		// this needs to be called in order to create the list of searchable
11 11
 		// classes and fields that are available.  Simulates part of a build
12
-		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO',
12
+		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO',
13 13
 			'FlickrTagTO', 'FlickrAuthorTO', 'FlickrSetTO');
14 14
 		$this->requireDefaultRecordsFrom = $classes;
15 15
 
Please login to merge, or discard this patch.
tests/models/FlickrModels.php 2 patches
Indentation   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -139,37 +139,37 @@  discard block
 block discarded – undo
139 139
 	 * Add a mapping for the location of the photograph
140 140
 	 */
141 141
 	public function updateElasticsearchMapping(\Elastica\Type\Mapping $mapping)
142
-    {
143
-    	// get the properties of the individual fields as an array
144
-    	$properties = $mapping->getProperties();
145
-
146
-    	// add a location with geo point
147
-    	$precision1cm = array('format' => 'compressed', 'precision' => '1cm');
148
-    	$properties['location'] =  array(
149
-    		'type' => 'geo_point',
150
-    		'fielddata' => $precision1cm,
151
-    	);
152
-
153
-    	$properties['ShutterSpeed'] = array(
154
-    		'type' => 'string',
155
-    		'index' => 'not_analyzed'
142
+	{
143
+		// get the properties of the individual fields as an array
144
+		$properties = $mapping->getProperties();
145
+
146
+		// add a location with geo point
147
+		$precision1cm = array('format' => 'compressed', 'precision' => '1cm');
148
+		$properties['location'] =  array(
149
+			'type' => 'geo_point',
150
+			'fielddata' => $precision1cm,
156 151
 		);
157 152
 
158
-    	$properties['Aperture'] = array(
159
-    		// do not use float as the rounding makes facets impossible
160
-    		'type' => 'double'
161
-    	);
153
+		$properties['ShutterSpeed'] = array(
154
+			'type' => 'string',
155
+			'index' => 'not_analyzed'
156
+		);
162 157
 
163
-    	$properties['FlickrID'] = array('type' => 'integer');
158
+		$properties['Aperture'] = array(
159
+			// do not use float as the rounding makes facets impossible
160
+			'type' => 'double'
161
+		);
164 162
 
165
-    	// by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s
166
-     	//$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s');
163
+		$properties['FlickrID'] = array('type' => 'integer');
167 164
 
168
-    	// set the new properties on the mapping
169
-    	$mapping->setProperties($properties);
165
+		// by default casted as a string, we want a date 2015-07-25 18:15:33 y-M-d H:m:s
166
+	 	//$properties['TakenAt'] = array('type' => 'date', 'format' => 'y-M-d H:m:s');
170 167
 
171
-        return $mapping;
172
-    }
168
+		// set the new properties on the mapping
169
+		$mapping->setProperties($properties);
170
+
171
+		return $mapping;
172
+	}
173 173
 
174 174
 
175 175
 	/**
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 		}
206 206
 		$sortable = $sortable . '|' . $this->owner->ShutterSpeed;
207 207
 		$document->set('ShutterSpeed', $sortable);
208
-	    return $document;
208
+		return $document;
209 209
 	}
210 210
 
211 211
 
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
  * @subpackage tests
7 7
  */
8 8
 class FlickrPhotoTO extends DataObject implements TestOnly {
9
-	private static $searchable_fields = array('Title','FlickrID','Description','TakenAt', 'TakenAtDT', 'FirstViewed',
10
-		'Aperture','ShutterSpeed','FocalLength35mm','ISO','AspectRatio', 'TestMethod', 'TestMethodHTML');
9
+	private static $searchable_fields = array('Title', 'FlickrID', 'Description', 'TakenAt', 'TakenAtDT', 'FirstViewed',
10
+		'Aperture', 'ShutterSpeed', 'FocalLength35mm', 'ISO', 'AspectRatio', 'TestMethod', 'TestMethodHTML');
11 11
 
12 12
 	private static $searchable_relationships = array('Photographer', 'FlickrTagTOs', 'FlickrSetTOs');
13 13
 
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
  * @subpackage tests
89 89
  */
90 90
 class FlickrSetTO extends DataObject implements TestOnly {
91
-	private static $searchable_fields = array('Title','FlickrID','Description');
91
+	private static $searchable_fields = array('Title', 'FlickrID', 'Description');
92 92
 
93 93
 	private static $db = array(
94 94
 		'Title' => 'Varchar(255)',
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 
134 134
 
135 135
 
136
-class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface,TestOnly {
136
+class FlickrPhotoTOTestIndexingExtension extends Extension implements ElasticaIndexingHelperInterface, TestOnly {
137 137
 
138 138
 	/**
139 139
 	 * Add a mapping for the location of the photograph
@@ -145,7 +145,7 @@  discard block
 block discarded – undo
145 145
 
146 146
     	// add a location with geo point
147 147
     	$precision1cm = array('format' => 'compressed', 'precision' => '1cm');
148
-    	$properties['location'] =  array(
148
+    	$properties['location'] = array(
149 149
     		'type' => 'geo_point',
150 150
     		'fielddata' => $precision1cm,
151 151
     	);
@@ -181,27 +181,27 @@  discard block
 block discarded – undo
181 181
 	{
182 182
 	//	self::$ctr++;
183 183
 
184
-		if ($this->owner->Lat != null && $this->owner->Lon != null) {
184
+		if($this->owner->Lat != null && $this->owner->Lon != null) {
185 185
 			$coors = array('lat' => $this->owner->Lat, 'lon' => $this->owner->Lon);
186
-			$document->set('location',$coors);
186
+			$document->set('location', $coors);
187 187
 		}
188 188
 
189 189
 		$sortable = $this->owner->ShutterSpeed;
190 190
 		$sortable = explode('/', $sortable);
191
-		if (sizeof($sortable) == 1) {
191
+		if(sizeof($sortable) == 1) {
192 192
 			$sortable = trim($sortable[0]);
193 193
 
194
-			if ($this->owner->ShutterSpeed == null) {
194
+			if($this->owner->ShutterSpeed == null) {
195 195
 				$sortable = null;
196 196
 			}
197 197
 
198
-			if ($sortable == 1) {
198
+			if($sortable == 1) {
199 199
 				$sortable = '1.000000';
200 200
 			}
201 201
 
202
-		} else if (sizeof($sortable) == 2) {
203
-			$sortable = floatval($sortable[0])/intval($sortable[1]);
204
-			$sortable = round($sortable,6);
202
+		} else if(sizeof($sortable) == 2) {
203
+			$sortable = floatval($sortable[0]) / intval($sortable[1]);
204
+			$sortable = round($sortable, 6);
205 205
 		}
206 206
 		$sortable = $sortable . '|' . $this->owner->ShutterSpeed;
207 207
 		$document->set('ShutterSpeed', $sortable);
Please login to merge, or discard this patch.