@@ -4,7 +4,7 @@ discard block  | 
                                                    ||
| 4 | 4 | /**  | 
                                                        
| 5 | 5 | * Alter the query or add to it, perhaps for example adding aggregation  | 
                                                        
| 6 | 6 | * @param Elastic\Query &$query query object from Elastica  | 
                                                        
| 7 | - * @return [type] [description]  | 
                                                        |
| 7 | + * @return void [description]  | 
                                                        |
| 8 | 8 | */  | 
                                                        
| 9 | 9 | public function augmentQuery(&$query);  | 
                                                        
| 10 | 10 | |
@@ -12,6 +12,7 @@ discard block  | 
                                                    ||
| 12 | 12 | * Update filters, perhaps remaps them, prior to performing a search.  | 
                                                        
| 13 | 13 | * This allows for aggregation values to be updated prior to rendering.  | 
                                                        
| 14 | 14 | * @param array &$filters array of key/value pairs for query filtering  | 
                                                        
| 15 | + * @return void  | 
                                                        |
| 15 | 16 | */  | 
                                                        
| 16 | 17 | public function updateFilters(&$filters);  | 
                                                        
| 17 | 18 | |
@@ -19,7 +20,7 @@ discard block  | 
                                                    ||
| 19 | 20 | * Manipulate the array of aggregations post search butprior to rendering  | 
                                                        
| 20 | 21 | * them in a template.  | 
                                                        
| 21 | 22 | * @param [type] &$aggs [description]  | 
                                                        
| 22 | - * @return [type] [description]  | 
                                                        |
| 23 | + * @return void [description]  | 
                                                        |
| 23 | 24 | */  | 
                                                        
| 24 | 25 | public function updateAggregation(&$aggs);  | 
                                                        
| 25 | 26 | |
@@ -250,6 +250,9 @@  | 
                                                    ||
| 250 | 250 | }  | 
                                                        
| 251 | 251 | |
| 252 | 252 | |
| 253 | + /**  | 
                                                        |
| 254 | + * @return integer  | 
                                                        |
| 255 | + */  | 
                                                        |
| 253 | 256 |  	public function getTotalItems() { | 
                                                        
| 254 | 257 | $this->getResults();  | 
                                                        
| 255 | 258 | return $this->TotalItems;  | 
                                                        
@@ -1036,6 +1036,7 @@  | 
                                                    ||
| 1036 | 1036 | /**  | 
                                                        
| 1037 | 1037 | * Test searching  | 
                                                        
| 1038 | 1038 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming  | 
                                                        
| 1039 | + * @param string $queryText  | 
                                                        |
| 1039 | 1040 | */  | 
                                                        
| 1040 | 1041 |  	private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), | 
                                                        
| 1041 | 1042 |  		$filters = array()) { | 
                                                        
@@ -421,7 +421,7 @@ discard block  | 
                                                    ||
| 421 | 421 |  		$resultList = $this->search(''); | 
                                                        
| 422 | 422 | |
| 423 | 423 | //assert there are actually some results  | 
                                                        
| 424 | - $this->assertGreaterThan(0,$resultList->getTotalItems());  | 
                                                        |
| 424 | + $this->assertGreaterThan(0, $resultList->getTotalItems());  | 
                                                        |
| 425 | 425 | $aggregations = $resultList->getAggregations()->toArray();  | 
                                                        
| 426 | 426 | |
| 427 | 427 | /*  | 
                                                        
@@ -440,49 +440,49 @@ discard block  | 
                                                    ||
| 440 | 440 | //Asserting aggregate of ISO, 64 has count 5  | 
                                                        
| 441 | 441 |  		$this->assertEquals("64", $buckets[0]->Key); | 
                                                        
| 442 | 442 | $this->assertEquals(5, $buckets[0]->DocumentCount);  | 
                                                        
| 443 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',64)->count(),5); | 
                                                        |
| 443 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 64)->count(), 5); | 
                                                        |
| 444 | 444 | $bucketSum += $buckets[0]->DocumentCount;  | 
                                                        
| 445 | 445 | |
| 446 | 446 | //Asserting aggregate of ISO, 100 has count 11  | 
                                                        
| 447 | 447 |  		$this->assertEquals("100", $buckets[1]->Key); | 
                                                        
| 448 | 448 | $this->assertEquals(11, $buckets[1]->DocumentCount);  | 
                                                        
| 449 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',100)->count(),11); | 
                                                        |
| 449 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 100)->count(), 11); | 
                                                        |
| 450 | 450 | $bucketSum += $buckets[1]->DocumentCount;  | 
                                                        
| 451 | 451 | |
| 452 | 452 | //Asserting aggregate of ISO, 200 has count 12  | 
                                                        
| 453 | 453 |  		$this->assertEquals("200", $buckets[2]->Key); | 
                                                        
| 454 | 454 | $this->assertEquals(12, $buckets[2]->DocumentCount);  | 
                                                        
| 455 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',200)->count(),12); | 
                                                        |
| 455 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 200)->count(), 12); | 
                                                        |
| 456 | 456 | $bucketSum += $buckets[2]->DocumentCount;  | 
                                                        
| 457 | 457 | |
| 458 | 458 | //Asserting aggregate of ISO, 400 has count 13  | 
                                                        
| 459 | 459 |  		$this->assertEquals("400", $buckets[3]->Key); | 
                                                        
| 460 | 460 | $this->assertEquals(13, $buckets[3]->DocumentCount);  | 
                                                        
| 461 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',400)->count(),13); | 
                                                        |
| 461 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 400)->count(), 13); | 
                                                        |
| 462 | 462 | $bucketSum += $buckets[3]->DocumentCount;  | 
                                                        
| 463 | 463 | |
| 464 | 464 | //Asserting aggregate of ISO, 800 has count 16  | 
                                                        
| 465 | 465 |  		$this->assertEquals("800", $buckets[4]->Key); | 
                                                        
| 466 | 466 | $this->assertEquals(16, $buckets[4]->DocumentCount);  | 
                                                        
| 467 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',800)->count(),16); | 
                                                        |
| 467 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 800)->count(), 16); | 
                                                        |
| 468 | 468 | $bucketSum += $buckets[4]->DocumentCount;  | 
                                                        
| 469 | 469 | |
| 470 | 470 | //Asserting aggregate of ISO, 1600 has count 13  | 
                                                        
| 471 | 471 |  		$this->assertEquals("1600", $buckets[5]->Key); | 
                                                        
| 472 | 472 | $this->assertEquals(13, $buckets[5]->DocumentCount);  | 
                                                        
| 473 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',1600)->count(),13); | 
                                                        |
| 473 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 1600)->count(), 13); | 
                                                        |
| 474 | 474 | $bucketSum += $buckets[5]->DocumentCount;  | 
                                                        
| 475 | 475 | |
| 476 | 476 | //Asserting aggregate of ISO, 2000 has count 11  | 
                                                        
| 477 | 477 |  		$this->assertEquals("2000", $buckets[6]->Key); | 
                                                        
| 478 | 478 | $this->assertEquals(11, $buckets[6]->DocumentCount);  | 
                                                        
| 479 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',2000)->count(),11); | 
                                                        |
| 479 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 2000)->count(), 11); | 
                                                        |
| 480 | 480 | $bucketSum += $buckets[6]->DocumentCount;  | 
                                                        
| 481 | 481 | |
| 482 | 482 | //Asserting aggregate of ISO, 3200 has count 19  | 
                                                        
| 483 | 483 |  		$this->assertEquals("3200", $buckets[7]->Key); | 
                                                        
| 484 | 484 | $this->assertEquals(19, $buckets[7]->DocumentCount);  | 
                                                        
| 485 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO',3200)->count(),19); | 
                                                        |
| 485 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('ISO', 3200)->count(), 19); | 
                                                        |
| 486 | 486 | $bucketSum += $buckets[7]->DocumentCount;  | 
                                                        
| 487 | 487 | $this->assertEquals(100, $bucketSum);  | 
                                                        
| 488 | 488 | |
@@ -495,43 +495,43 @@ discard block  | 
                                                    ||
| 495 | 495 | //Asserting aggregate of Focal Length, 24 has count 12  | 
                                                        
| 496 | 496 |  		$this->assertEquals("24", $buckets[0]->Key); | 
                                                        
| 497 | 497 | $this->assertEquals(12, $buckets[0]->DocumentCount);  | 
                                                        
| 498 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',24)->count(),12); | 
                                                        |
| 498 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 24)->count(), 12); | 
                                                        |
| 499 | 499 | $bucketSum += $buckets[0]->DocumentCount;  | 
                                                        
| 500 | 500 | |
| 501 | 501 | //Asserting aggregate of Focal Length, 50 has count 11  | 
                                                        
| 502 | 502 |  		$this->assertEquals("50", $buckets[1]->Key); | 
                                                        
| 503 | 503 | $this->assertEquals(11, $buckets[1]->DocumentCount);  | 
                                                        
| 504 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',50)->count(),11); | 
                                                        |
| 504 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 50)->count(), 11); | 
                                                        |
| 505 | 505 | $bucketSum += $buckets[1]->DocumentCount;  | 
                                                        
| 506 | 506 | |
| 507 | 507 | //Asserting aggregate of Focal Length, 80 has count 11  | 
                                                        
| 508 | 508 |  		$this->assertEquals("80", $buckets[2]->Key); | 
                                                        
| 509 | 509 | $this->assertEquals(11, $buckets[2]->DocumentCount);  | 
                                                        
| 510 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',80)->count(),11); | 
                                                        |
| 510 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 80)->count(), 11); | 
                                                        |
| 511 | 511 | $bucketSum += $buckets[2]->DocumentCount;  | 
                                                        
| 512 | 512 | |
| 513 | 513 | //Asserting aggregate of Focal Length, 90 has count 20  | 
                                                        
| 514 | 514 |  		$this->assertEquals("90", $buckets[3]->Key); | 
                                                        
| 515 | 515 | $this->assertEquals(20, $buckets[3]->DocumentCount);  | 
                                                        
| 516 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',90)->count(),20); | 
                                                        |
| 516 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 90)->count(), 20); | 
                                                        |
| 517 | 517 | $bucketSum += $buckets[3]->DocumentCount;  | 
                                                        
| 518 | 518 | |
| 519 | 519 | //Asserting aggregate of Focal Length, 120 has count 12  | 
                                                        
| 520 | 520 |  		$this->assertEquals("120", $buckets[4]->Key); | 
                                                        
| 521 | 521 | $this->assertEquals(12, $buckets[4]->DocumentCount);  | 
                                                        
| 522 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',120)->count(),12); | 
                                                        |
| 522 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 120)->count(), 12); | 
                                                        |
| 523 | 523 | $bucketSum += $buckets[4]->DocumentCount;  | 
                                                        
| 524 | 524 | |
| 525 | 525 | //Asserting aggregate of Focal Length, 150 has count 17  | 
                                                        
| 526 | 526 |  		$this->assertEquals("150", $buckets[5]->Key); | 
                                                        
| 527 | 527 | $this->assertEquals(17, $buckets[5]->DocumentCount);  | 
                                                        
| 528 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',150)->count(),17); | 
                                                        |
| 528 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 150)->count(), 17); | 
                                                        |
| 529 | 529 | $bucketSum += $buckets[5]->DocumentCount;  | 
                                                        
| 530 | 530 | |
| 531 | 531 | //Asserting aggregate of Focal Length, 200 has count 17  | 
                                                        
| 532 | 532 |  		$this->assertEquals("200", $buckets[6]->Key); | 
                                                        
| 533 | 533 | $this->assertEquals(17, $buckets[6]->DocumentCount);  | 
                                                        
| 534 | -		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm',200)->count(),17); | 
                                                        |
| 534 | +		$this->assertEquals(FlickrPhotoTO::get()->filter('FocalLength35mm', 200)->count(), 17); | 
                                                        |
| 535 | 535 | $bucketSum += $buckets[6]->DocumentCount;  | 
                                                        
| 536 | 536 | $this->assertEquals(100, $bucketSum);  | 
                                                        
| 537 | 537 | |
@@ -731,7 +731,7 @@ discard block  | 
                                                    ||
| 731 | 731 | $buckets = $agg->Buckets->toArray();  | 
                                                        
| 732 | 732 | |
| 733 | 733 | |
| 734 | -		foreach ($buckets as $bucket) { | 
                                                        |
| 734 | +		foreach($buckets as $bucket) { | 
                                                        |
| 735 | 735 |  			echo "{$bucket->Key} => {$bucket->DocumentCount}\n"; | 
                                                        
| 736 | 736 | }  | 
                                                        
| 737 | 737 | |
@@ -825,7 +825,7 @@ discard block  | 
                                                    ||
| 825 | 825 | $originalAggregations = $resultList->getAggregations()->toArray();  | 
                                                        
| 826 | 826 | |
| 827 | 827 |  		$filters = array('ISO' => 3200); | 
                                                        
| 828 | -		$resultListFiltered = $this->search('New Zealand', $fields,$filters); | 
                                                        |
| 828 | +		$resultListFiltered = $this->search('New Zealand', $fields, $filters); | 
                                                        |
| 829 | 829 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray();  | 
                                                        
| 830 | 830 | |
| 831 | 831 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);  | 
                                                        
@@ -837,8 +837,8 @@ discard block  | 
                                                    ||
| 837 | 837 |  		$resultList = $this->search('New Zealand', $fields, array('ISO' => 400)); | 
                                                        
| 838 | 838 | $originalAggregations = $resultList->getAggregations()->toArray();  | 
                                                        
| 839 | 839 | |
| 840 | -		$filters = array('ISO' => 400, 'Aspect' => 'Vertical' ); | 
                                                        |
| 841 | -		$resultListFiltered = $this->search('New Zealand', $fields,$filters); | 
                                                        |
| 840 | +		$filters = array('ISO' => 400, 'Aspect' => 'Vertical'); | 
                                                        |
| 841 | +		$resultListFiltered = $this->search('New Zealand', $fields, $filters); | 
                                                        |
| 842 | 842 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray();  | 
                                                        
| 843 | 843 | |
| 844 | 844 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);  | 
                                                        
@@ -854,8 +854,8 @@ discard block  | 
                                                    ||
| 854 | 854 | 'Aspect' => 'Vertical'));  | 
                                                        
| 855 | 855 | $originalAggregations = $resultList->getAggregations()->toArray();  | 
                                                        
| 856 | 856 | |
| 857 | -		$filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5 ); | 
                                                        |
| 858 | -		$resultListFiltered = $this->search('New Zealand', $fields,$filters); | 
                                                        |
| 857 | +		$filters = array('ISO' => 400, 'Aspect' => 'Vertical', 'Aperture' => 5); | 
                                                        |
| 858 | +		$resultListFiltered = $this->search('New Zealand', $fields, $filters); | 
                                                        |
| 859 | 859 | $filteredAggregations = $resultListFiltered->getAggregations()->toArray();  | 
                                                        
| 860 | 860 | |
| 861 | 861 | $this->checkDrillingDownHasHappened($filteredAggregations, $originalAggregations);  | 
                                                        
@@ -895,7 +895,7 @@ discard block  | 
                                                    ||
| 895 | 895 |  	private function checkDrillingDownHasHappened($filteredAggregations, $originalAggregations) { | 
                                                        
| 896 | 896 | $aggCtr = 0;  | 
                                                        
| 897 | 897 | |
| 898 | -		foreach ($filteredAggregations as $filteredAgg) { | 
                                                        |
| 898 | +		foreach($filteredAggregations as $filteredAgg) { | 
                                                        |
| 899 | 899 | $origAgg = $originalAggregations[$aggCtr];  | 
                                                        
| 900 | 900 | $bucketCtr = 0;  | 
                                                        
| 901 | 901 | $origBuckets = $origAgg->Buckets->toArray();  | 
                                                        
@@ -904,17 +904,17 @@ discard block  | 
                                                    ||
| 904 | 904 | $origCounts = array();  | 
                                                        
| 905 | 905 | $filteredCounts = array();  | 
                                                        
| 906 | 906 | |
| 907 | -			foreach ($origBuckets as $bucket) { | 
                                                        |
| 907 | +			foreach($origBuckets as $bucket) { | 
                                                        |
| 908 | 908 | $origCounts[$bucket->Key] = $bucket->DocumentCount;  | 
                                                        
| 909 | 909 | }  | 
                                                        
| 910 | 910 | |
| 911 | -			foreach ($filteredBuckets as $bucket) { | 
                                                        |
| 911 | +			foreach($filteredBuckets as $bucket) { | 
                                                        |
| 912 | 912 | $filteredCounts[$bucket->Key] = $bucket->DocumentCount;  | 
                                                        
| 913 | 913 | }  | 
                                                        
| 914 | 914 | |
| 915 | 915 | $akf = array_keys($filteredCounts);  | 
                                                        
| 916 | 916 | |
| 917 | -			foreach ($akf as $aggregateKey) { | 
                                                        |
| 917 | +			foreach($akf as $aggregateKey) { | 
                                                        |
| 918 | 918 | $this->assertGreaterThanOrEqual(  | 
                                                        
| 919 | 919 | $filteredCounts[$aggregateKey], $origCounts[$aggregateKey]  | 
                                                        
| 920 | 920 | );  | 
                                                        
@@ -950,8 +950,8 @@ discard block  | 
                                                    ||
| 950 | 950 |  		$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); | 
                                                        
| 951 | 951 | |
| 952 | 952 | //Add filters  | 
                                                        
| 953 | -		foreach ($filters as $key => $value) { | 
                                                        |
| 954 | - $es->addFilter($key,$value);  | 
                                                        |
| 953 | +		foreach($filters as $key => $value) { | 
                                                        |
| 954 | + $es->addFilter($key, $value);  | 
                                                        |
| 955 | 955 | }  | 
                                                        
| 956 | 956 | |
| 957 | 957 | $es->showResultsForEmptySearch();  | 
                                                        
@@ -970,7 +970,7 @@ discard block  | 
                                                    ||
| 970 | 970 | * Test searching  | 
                                                        
| 971 | 971 | * http://stackoverflow.com/questions/28305250/elasticsearch-customize-score-for-synonyms-stemming  | 
                                                        
| 972 | 972 | */  | 
                                                        
| 973 | -	private function search($queryText,$fields = array('Title' => 1, 'Description' => 1), | 
                                                        |
| 973 | +	private function search($queryText, $fields = array('Title' => 1, 'Description' => 1), | 
                                                        |
| 974 | 974 |  		$filters = array()) { | 
                                                        
| 975 | 975 | $es = new ElasticSearcher();  | 
                                                        
| 976 | 976 | $es->setStart(0);  | 
                                                        
@@ -980,9 +980,9 @@ discard block  | 
                                                    ||
| 980 | 980 |  		$es->setQueryResultManipulator('FlickrPhotoTOElasticaSearchHelper'); | 
                                                        
| 981 | 981 | |
| 982 | 982 | //Add filters  | 
                                                        
| 983 | -		foreach ($filters as $key => $value) { | 
                                                        |
| 983 | +		foreach($filters as $key => $value) { | 
                                                        |
| 984 | 984 | echo "ADDING FILTER:$key => $value\n";  | 
                                                        
| 985 | - $es->addFilter($key,$value);  | 
                                                        |
| 985 | + $es->addFilter($key, $value);  | 
                                                        |
| 986 | 986 | }  | 
                                                        
| 987 | 987 | |
| 988 | 988 | $es->showResultsForEmptySearch();  | 
                                                        
@@ -991,12 +991,12 @@ discard block  | 
                                                    ||
| 991 | 991 | $ctr = 0;  | 
                                                        
| 992 | 992 | |
| 993 | 993 |  		echo "{$resultList->count()} items found searching for '$queryText'\n\n"; | 
                                                        
| 994 | -		foreach ($resultList as $result) { | 
                                                        |
| 994 | +		foreach($resultList as $result) { | 
                                                        |
| 995 | 995 | $ctr++;  | 
                                                        
| 996 | -			echo("($ctr) ".$result->Title."\n"); | 
                                                        |
| 997 | -			if ($result->SearchHighlightsByField->Content) { | 
                                                        |
| 998 | -				foreach ($result->SearchHighlightsByField->Content as $highlight) { | 
                                                        |
| 999 | -					echo("- ".$highlight->Snippet); | 
                                                        |
| 996 | +			echo("($ctr) " . $result->Title . "\n"); | 
                                                        |
| 997 | +			if($result->SearchHighlightsByField->Content) { | 
                                                        |
| 998 | +				foreach($result->SearchHighlightsByField->Content as $highlight) { | 
                                                        |
| 999 | +					echo("- " . $highlight->Snippet); | 
                                                        |
| 1000 | 1000 | }  | 
                                                        
| 1001 | 1001 | }  | 
                                                        
| 1002 | 1002 | }  | 
                                                        
@@ -153,6 +153,9 @@  | 
                                                    ||
| 153 | 153 | |
| 154 | 154 | /**  | 
                                                        
| 155 | 155 | * Simulate a call to Elastica to get suggestions for a given phrase  | 
                                                        
| 156 | + * @param string $phrase  | 
                                                        |
| 157 | + * @param string $suggestion  | 
                                                        |
| 158 | + * @param string $highlightedSuggestion  | 
                                                        |
| 156 | 159 | * @return [type] [description]  | 
                                                        
| 157 | 160 | */  | 
                                                        
| 158 | 161 |  	private function getSuggestionArray($phrase, $suggestion, $highlightedSuggestion) { | 
                                                        
@@ -102,7 +102,7 @@ discard block  | 
                                                    ||
| 102 | 102 | * Note:   characters are stripped from the content; make sure that your assertions take this into account.  | 
                                                        
| 103 | 103 | *  | 
                                                        
| 104 | 104 | * @param string $selector A basic CSS selector, e.g. 'li.jobs h3'  | 
                                                        
| 105 | - * @param array|string $expectedMatches The content of at least one of the matched tags  | 
                                                        |
| 105 | + * @param integer $index  | 
                                                        |
| 106 | 106 | * @throws PHPUnit_Framework_AssertionFailedError  | 
                                                        
| 107 | 107 | * @return boolean  | 
                                                        
| 108 | 108 | */  | 
                                                        
@@ -133,6 +133,12 @@ discard block  | 
                                                    ||
| 133 | 133 | /*  | 
                                                        
| 134 | 134 | Check all the nodes matching the selector for attribute name = expected value  | 
                                                        
| 135 | 135 | */  | 
                                                        
| 136 | +  | 
                                                        |
| 137 | + /**  | 
                                                        |
| 138 | + * @param string $selector  | 
                                                        |
| 139 | + * @param string $attributeName  | 
                                                        |
| 140 | + * @param string $expectedValue  | 
                                                        |
| 141 | + */  | 
                                                        |
| 136 | 142 |  	public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { | 
                                                        
| 137 | 143 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 138 | 144 |  		foreach ($items as $item) { | 
                                                        
@@ -141,6 +147,9 @@ discard block  | 
                                                    ||
| 141 | 147 | }  | 
                                                        
| 142 | 148 | |
| 143 | 149 | |
| 150 | + /**  | 
                                                        |
| 151 | + * @param string $selector  | 
                                                        |
| 152 | + */  | 
                                                        |
| 144 | 153 |  	public function assertAttributesHaveExactValues($selector, $expectedValues) { | 
                                                        
| 145 | 154 | $attributeNames = array_keys($expectedValues);  | 
                                                        
| 146 | 155 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
@@ -154,6 +163,10 @@ discard block  | 
                                                    ||
| 154 | 163 | }  | 
                                                        
| 155 | 164 | |
| 156 | 165 | |
| 166 | + /**  | 
                                                        |
| 167 | + * @param string $selector  | 
                                                        |
| 168 | + * @param integer $expectedAmount  | 
                                                        |
| 169 | + */  | 
                                                        |
| 157 | 170 |  	public function assertNumberOfNodes($selector, $expectedAmount) { | 
                                                        
| 158 | 171 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 159 | 172 |  		foreach ($items as $item) { | 
                                                        
@@ -8,8 +8,8 @@ discard block  | 
                                                    ||
| 8 | 8 | public static $ignoreFixtureFileFor = array();  | 
                                                        
| 9 | 9 | |
| 10 | 10 | protected $extraDataObjects = array(  | 
                                                        
| 11 | - 'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO',  | 
                                                        |
| 12 | - 'SearchableTestFatherPage','SearchableTestGrandFatherPage'  | 
                                                        |
| 11 | + 'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO',  | 
                                                        |
| 12 | + 'SearchableTestFatherPage', 'SearchableTestGrandFatherPage'  | 
                                                        |
| 13 | 13 | );  | 
                                                        
| 14 | 14 | |
| 15 | 15 | |
@@ -29,7 +29,7 @@ discard block  | 
                                                    ||
| 29 | 29 | |
| 30 | 30 | // this needs to be called in order to create the list of searchable  | 
                                                        
| 31 | 31 | // classes and fields that are available. Simulates part of a build  | 
                                                        
| 32 | -		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', | 
                                                        |
| 32 | +		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', | 
                                                        |
| 33 | 33 | 'FlickrTagTO', 'FlickrAuthorTO');  | 
                                                        
| 34 | 34 | $this->requireDefaultRecordsFrom = $classes;  | 
                                                        
| 35 | 35 | |
@@ -45,7 +45,7 @@ discard block  | 
                                                    ||
| 45 | 45 | $this->service->setTestMode(true);  | 
                                                        
| 46 | 46 | |
| 47 | 47 | // A previous test may have deleted the index and then failed, so check for this  | 
                                                        
| 48 | -		if (!$this->service->getIndex()->exists()) { | 
                                                        |
| 48 | +		if(!$this->service->getIndex()->exists()) { | 
                                                        |
| 49 | 49 | $this->service->getIndex()->create();  | 
                                                        
| 50 | 50 | }  | 
                                                        
| 51 | 51 | $this->service->reset();  | 
                                                        
@@ -59,10 +59,10 @@ discard block  | 
                                                    ||
| 59 | 59 | echo "TESTS TO IGNORE:\n";  | 
                                                        
| 60 | 60 | print_r(static::$ignoreFixtureFileFor);  | 
                                                        
| 61 | 61 | |
| 62 | -		foreach (static::$ignoreFixtureFileFor as $testPattern) { | 
                                                        |
| 63 | - $pattern = '/'.$testPattern.'/';  | 
                                                        |
| 64 | - echo "GREP: $pattern against ".$this->getName()."\n";  | 
                                                        |
| 65 | -			if (preg_match($pattern, $this->getName())) { | 
                                                        |
| 62 | +		foreach(static::$ignoreFixtureFileFor as $testPattern) { | 
                                                        |
| 63 | + $pattern = '/' . $testPattern . '/';  | 
                                                        |
| 64 | + echo "GREP: $pattern against " . $this->getName() . "\n";  | 
                                                        |
| 65 | +			if(preg_match($pattern, $this->getName())) { | 
                                                        |
| 66 | 66 | static::$fixture_file = null;  | 
                                                        
| 67 | 67 | }  | 
                                                        
| 68 | 68 | }  | 
                                                        
@@ -84,12 +84,12 @@ discard block  | 
                                                    ||
| 84 | 84 | |
| 85 | 85 | |
| 86 | 86 |  	private function publishSiteTree() { | 
                                                        
| 87 | -		foreach (SiteTree::get()->getIterator() as $page) { | 
                                                        |
| 87 | +		foreach(SiteTree::get()->getIterator() as $page) { | 
                                                        |
| 88 | 88 | // temporarily disable Elasticsearch indexing, it will be done in a batch  | 
                                                        
| 89 | 89 | $page->IndexingOff = true;  | 
                                                        
| 90 | 90 | |
| 91 | - echo "Publishing ".$page->Title."\n";  | 
                                                        |
| 92 | -			$page->publish('Stage','Live'); | 
                                                        |
| 91 | + echo "Publishing " . $page->Title . "\n";  | 
                                                        |
| 92 | +			$page->publish('Stage', 'Live'); | 
                                                        |
| 93 | 93 | }  | 
                                                        
| 94 | 94 | }  | 
                                                        
| 95 | 95 | |
@@ -111,11 +111,11 @@ discard block  | 
                                                    ||
| 111 | 111 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 112 | 112 | |
| 113 | 113 | $ctr = 0;  | 
                                                        
| 114 | -		foreach ($items as $item) { | 
                                                        |
| 114 | +		foreach($items as $item) { | 
                                                        |
| 115 | 115 | $text = strip_tags($item);  | 
                                                        
| 116 | 116 |  			$escaped = str_replace("'", "\'", $text); | 
                                                        
| 117 | 117 |  			echo "SELECTED:\$this->assertSelectorStartsWithOrEquals('{$selector}', $ctr, '$escaped');\n"; | 
                                                        
| 118 | - echo "ITEM:".$item."\n";  | 
                                                        |
| 118 | + echo "ITEM:" . $item . "\n";  | 
                                                        |
| 119 | 119 | $ctr++;  | 
                                                        
| 120 | 120 | }  | 
                                                        
| 121 | 121 | |
@@ -135,7 +135,7 @@ discard block  | 
                                                    ||
| 135 | 135 | */  | 
                                                        
| 136 | 136 |  	public function assertAttributeHasExactValue($selector, $attributeName, $expectedValue) { | 
                                                        
| 137 | 137 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 138 | -		foreach ($items as $item) { | 
                                                        |
| 138 | +		foreach($items as $item) { | 
                                                        |
| 139 | 139 | $this->assertEquals($expectedValue, $item['value']);  | 
                                                        
| 140 | 140 | }  | 
                                                        
| 141 | 141 | }  | 
                                                        
@@ -144,9 +144,9 @@ discard block  | 
                                                    ||
| 144 | 144 |  	public function assertAttributesHaveExactValues($selector, $expectedValues) { | 
                                                        
| 145 | 145 | $attributeNames = array_keys($expectedValues);  | 
                                                        
| 146 | 146 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 147 | -		foreach ($items as $item) { | 
                                                        |
| 147 | +		foreach($items as $item) { | 
                                                        |
| 148 | 148 | $actualValues = array();  | 
                                                        
| 149 | -			foreach ($attributeNames as $attributeName) { | 
                                                        |
| 149 | +			foreach($attributeNames as $attributeName) { | 
                                                        |
| 150 | 150 | $actualValues[$attributeName] = (string)$item[$attributeName];  | 
                                                        
| 151 | 151 | }  | 
                                                        
| 152 | 152 | $this->assertEquals($expectedValues, $actualValues);  | 
                                                        
@@ -156,7 +156,7 @@ discard block  | 
                                                    ||
| 156 | 156 | |
| 157 | 157 |  	public function assertNumberOfNodes($selector, $expectedAmount) { | 
                                                        
| 158 | 158 | $items = $this->cssParser()->getBySelector($selector);  | 
                                                        
| 159 | -		foreach ($items as $item) { | 
                                                        |
| 159 | +		foreach($items as $item) { | 
                                                        |
| 160 | 160 | $text = strip_tags($item);  | 
                                                        
| 161 | 161 | }  | 
                                                        
| 162 | 162 | |
@@ -169,9 +169,9 @@ discard block  | 
                                                    ||
| 169 | 169 |  	public function collateSearchResults() { | 
                                                        
| 170 | 170 |  		$items = $this->cssParser()->getBySelector('div.searchResults .searchResult'); | 
                                                        
| 171 | 171 | $result = array();  | 
                                                        
| 172 | -		foreach ($items as $item) { | 
                                                        |
| 172 | +		foreach($items as $item) { | 
                                                        |
| 173 | 173 | $attr = $item->attributes()->id;  | 
                                                        
| 174 | - array_push($result, $attr."");  | 
                                                        |
| 174 | + array_push($result, $attr . "");  | 
                                                        |
| 175 | 175 | }  | 
                                                        
| 176 | 176 | |
| 177 | 177 | return $result;  | 
                                                        
@@ -106,6 +106,10 @@  | 
                                                    ||
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | 108 | |
| 109 | + /**  | 
                                                        |
| 110 | + * @param string $fieldName  | 
                                                        |
| 111 | + * @param string $message  | 
                                                        |
| 112 | + */  | 
                                                        |
| 109 | 113 |  	private function checkForError($fieldName, $badValue, $message) { | 
                                                        
| 110 | 114 | $this->ElasticSearchPage->$fieldName = $badValue;  | 
                                                        
| 111 | 115 | |
@@ -8,7 +8,7 @@ discard block  | 
                                                    ||
| 8 | 8 | parent::setup();  | 
                                                        
| 9 | 9 |  		$this->ElasticSearchPage = $this->objFromFixture('ElasticSearchPage', 'search'); | 
                                                        
| 10 | 10 | |
| 11 | - $this->ElasticSearchPage->SimilarityStopWords = 'a,the,which';  | 
                                                        |
| 11 | + $this->ElasticSearchPage->SimilarityStopWords = 'a,the,which';  | 
                                                        |
| 12 | 12 | $this->ElasticSearchPage->write();  | 
                                                        
| 13 | 13 | |
| 14 | 14 | $this->Validator = $this->ElasticSearchPage->getCMSValidator();  | 
                                                        
@@ -34,7 +34,7 @@ discard block  | 
                                                    ||
| 34 | 34 | 'AutoCompleteFieldID' => null,  | 
                                                        
| 35 | 35 | 'AutoCompleteFunctionID' => null,  | 
                                                        
| 36 | 36 | 'SearchHelper' => null,  | 
                                                        
| 37 | -			'SimilarityStopWords' => array('a', 'an', 'the', ), | 
                                                        |
| 37 | +			'SimilarityStopWords' => array('a', 'an', 'the',), | 
                                                        |
| 38 | 38 | 'MinTermFreq' => 2,  | 
                                                        
| 39 | 39 | 'MaxTermFreq' => 25,  | 
                                                        
| 40 | 40 | 'MinDocFreq' => 2,  | 
                                                        
@@ -102,7 +102,7 @@ discard block  | 
                                                    ||
| 102 | 102 | $esp->Identifier = 'THISWILLBECOPIED';  | 
                                                        
| 103 | 103 | $esp->write();  | 
                                                        
| 104 | 104 |  		$this->checkForError('Identifier', 'THISWILLBECOPIED', | 
                                                        
| 105 | - 'The identifier THISWILLBECOPIED already exists' );  | 
                                                        |
| 105 | + 'The identifier THISWILLBECOPIED already exists');  | 
                                                        |
| 106 | 106 | }  | 
                                                        
| 107 | 107 | |
| 108 | 108 | |
@@ -114,7 +114,7 @@ discard block  | 
                                                    ||
| 114 | 114 | $form = new Form($this, 'Form', $fields, new FieldList());  | 
                                                        
| 115 | 115 | $form->loadDataFrom($this->ElasticSearchPage);  | 
                                                        
| 116 | 116 | |
| 117 | -		foreach ($form->Fields() as $field) { | 
                                                        |
| 117 | +		foreach($form->Fields() as $field) { | 
                                                        |
| 118 | 118 |  			echo "************** {$field->getName()} -> {$field->Value()}\n"; | 
                                                        
| 119 | 119 | }  | 
                                                        
| 120 | 120 | $form->setValidator($this->ElasticSearchPage->getCMSValidator());  | 
                                                        
@@ -124,13 +124,13 @@ discard block  | 
                                                    ||
| 124 | 124 | $found = false;  | 
                                                        
| 125 | 125 | print_r($errors);  | 
                                                        
| 126 | 126 | |
| 127 | -		foreach ($errors as $error) { | 
                                                        |
| 127 | +		foreach($errors as $error) { | 
                                                        |
| 128 | 128 | echo "Checking error\n";  | 
                                                        
| 129 | - echo " - " . $error['fieldName'].' => '.$error['message']."\n";  | 
                                                        |
| 130 | - echo "\tT1:".($error['message'] == $message);  | 
                                                        |
| 131 | - echo "\n\tT2:".($error['fieldName'] == $fieldName);  | 
                                                        |
| 129 | + echo " - " . $error['fieldName'] . ' => ' . $error['message'] . "\n";  | 
                                                        |
| 130 | + echo "\tT1:" . ($error['message'] == $message);  | 
                                                        |
| 131 | + echo "\n\tT2:" . ($error['fieldName'] == $fieldName);  | 
                                                        |
| 132 | 132 | |
| 133 | -			if ($error['message'] == $message && $error['fieldName'] == $fieldName) { | 
                                                        |
| 133 | +			if($error['message'] == $message && $error['fieldName'] == $fieldName) { | 
                                                        |
| 134 | 134 | $found = true;  | 
                                                        
| 135 | 135 | break;  | 
                                                        
| 136 | 136 | }  | 
                                                        
@@ -132,6 +132,10 @@ discard block  | 
                                                    ||
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | |
| 135 | + /**  | 
                                                        |
| 136 | + * @param integer $depth  | 
                                                        |
| 137 | + * @param string $parentKey  | 
                                                        |
| 138 | + */  | 
                                                        |
| 135 | 139 |  	private function recurseArrayAssertion($toAssert, $depth, $parentKey) { | 
                                                        
| 136 | 140 |  		$prefix = str_repeat("\t",$depth); | 
                                                        
| 137 | 141 |  		echo "\t{$prefix}'$parentKey' => array(\n"; | 
                                                        
@@ -160,6 +164,10 @@ discard block  | 
                                                    ||
| 160 | 164 | /*  | 
                                                        
| 161 | 165 | Helper methods for testing CMS fields  | 
                                                        
| 162 | 166 | */  | 
                                                        
| 167 | +  | 
                                                        |
| 168 | + /**  | 
                                                        |
| 169 | + * @param string $tabName  | 
                                                        |
| 170 | + */  | 
                                                        |
| 163 | 171 |  	public function checkTabExists($fields, $tabName) { | 
                                                        
| 164 | 172 | echo "Searching for tab $tabName\n";  | 
                                                        
| 165 | 173 |  		$tab = $fields->findOrMakeTab("Root.{$tabName}"); | 
                                                        
@@ -184,6 +192,9 @@ discard block  | 
                                                    ||
| 184 | 192 | }  | 
                                                        
| 185 | 193 | |
| 186 | 194 | |
| 195 | + /**  | 
                                                        |
| 196 | + * @param string $fieldName  | 
                                                        |
| 197 | + */  | 
                                                        |
| 187 | 198 |  	public function checkFieldExists($tab,$fieldName) { | 
                                                        
| 188 | 199 | $fields = $tab->Fields();  | 
                                                        
| 189 | 200 |  		echo "TAB:{$tab->Name}\n"; | 
                                                        
@@ -208,11 +208,11 @@  | 
                                                    ||
| 208 | 208 | */  | 
                                                        
| 209 | 209 | public function invokeMethod(&$object, $methodName, array $parameters = array())  | 
                                                        
| 210 | 210 |  	{ | 
                                                        
| 211 | - $reflection = new \ReflectionClass(get_class($object));  | 
                                                        |
| 212 | - $method = $reflection->getMethod($methodName);  | 
                                                        |
| 213 | - $method->setAccessible(true);  | 
                                                        |
| 211 | + $reflection = new \ReflectionClass(get_class($object));  | 
                                                        |
| 212 | + $method = $reflection->getMethod($methodName);  | 
                                                        |
| 213 | + $method->setAccessible(true);  | 
                                                        |
| 214 | 214 | |
| 215 | - return $method->invokeArgs($object, $parameters);  | 
                                                        |
| 215 | + return $method->invokeArgs($object, $parameters);  | 
                                                        |
| 216 | 216 | }  | 
                                                        
| 217 | 217 | |
| 218 | 218 | |
@@ -9,8 +9,8 @@ discard block  | 
                                                    ||
| 9 | 9 | public static $ignoreFixtureFileFor = array();  | 
                                                        
| 10 | 10 | |
| 11 | 11 | protected $extraDataObjects = array(  | 
                                                        
| 12 | - 'SearchableTestPage','FlickrPhotoTO','FlickrAuthorTO','FlickrSetTO','FlickrTagTO',  | 
                                                        |
| 13 | - 'SearchableTestFatherPage','SearchableTestGrandFatherPage','AutoCompleteOption'  | 
                                                        |
| 12 | + 'SearchableTestPage', 'FlickrPhotoTO', 'FlickrAuthorTO', 'FlickrSetTO', 'FlickrTagTO',  | 
                                                        |
| 13 | + 'SearchableTestFatherPage', 'SearchableTestGrandFatherPage', 'AutoCompleteOption'  | 
                                                        |
| 14 | 14 | );  | 
                                                        
| 15 | 15 | |
| 16 | 16 | |
@@ -39,7 +39,7 @@ discard block  | 
                                                    ||
| 39 | 39 | |
| 40 | 40 | // this needs to be called in order to create the list of searchable  | 
                                                        
| 41 | 41 | // classes and fields that are available. Simulates part of a build  | 
                                                        
| 42 | -		$classes = array('SearchableTestPage','SiteTree','Page','FlickrPhotoTO','FlickrSetTO', | 
                                                        |
| 42 | +		$classes = array('SearchableTestPage', 'SiteTree', 'Page', 'FlickrPhotoTO', 'FlickrSetTO', | 
                                                        |
| 43 | 43 | 'FlickrTagTO', 'FlickrAuthorTO');  | 
                                                        
| 44 | 44 | $this->requireDefaultRecordsFrom = $classes;  | 
                                                        
| 45 | 45 | |
@@ -49,7 +49,7 @@ discard block  | 
                                                    ||
| 49 | 49 | $this->service->setTestMode(true);  | 
                                                        
| 50 | 50 | |
| 51 | 51 | // A previous test may have deleted the index and then failed, so check for this  | 
                                                        
| 52 | -		if (!$this->service->getIndex()->exists()) { | 
                                                        |
| 52 | +		if(!$this->service->getIndex()->exists()) { | 
                                                        |
| 53 | 53 | $this->service->getIndex()->create();  | 
                                                        
| 54 | 54 | }  | 
                                                        
| 55 | 55 | $this->service->reset();  | 
                                                        
@@ -60,14 +60,14 @@ discard block  | 
                                                    ||
| 60 | 60 | |
| 61 | 61 | $orig_fixture_file = static::$fixture_file;  | 
                                                        
| 62 | 62 | |
| 63 | -		foreach (static::$ignoreFixtureFileFor as $testPattern) { | 
                                                        |
| 64 | - $pattern = '/'.$testPattern.'/';  | 
                                                        |
| 65 | -			if (preg_match($pattern, $this->getName())) { | 
                                                        |
| 63 | +		foreach(static::$ignoreFixtureFileFor as $testPattern) { | 
                                                        |
| 64 | + $pattern = '/' . $testPattern . '/';  | 
                                                        |
| 65 | +			if(preg_match($pattern, $this->getName())) { | 
                                                        |
| 66 | 66 | static::$fixture_file = null;  | 
                                                        
| 67 | 67 | }  | 
                                                        
| 68 | 68 | }  | 
                                                        
| 69 | 69 | |
| 70 | -		echo "\n\n\n\nEXECUTING TEST {$this->getName()}, FIXTURES=".static::$fixture_file."\n"; | 
                                                        |
| 70 | +		echo "\n\n\n\nEXECUTING TEST {$this->getName()}, FIXTURES=" . static::$fixture_file . "\n"; | 
                                                        |
| 71 | 71 | |
| 72 | 72 | parent::setUp();  | 
                                                        
| 73 | 73 | static::$fixture_file = $orig_fixture_file;  | 
                                                        
@@ -93,57 +93,57 @@ discard block  | 
                                                    ||
| 93 | 93 | |
| 94 | 94 | |
| 95 | 95 |  	private function publishSiteTree() { | 
                                                        
| 96 | -		foreach (SiteTree::get()->getIterator() as $page) { | 
                                                        |
| 96 | +		foreach(SiteTree::get()->getIterator() as $page) { | 
                                                        |
| 97 | 97 | // temporarily disable Elasticsearch indexing, it will be done in a batch  | 
                                                        
| 98 | 98 | $page->IndexingOff = true;  | 
                                                        
| 99 | 99 | |
| 100 | - echo "Publishing ".$page->Title."\n";  | 
                                                        |
| 101 | -			$page->publish('Stage','Live'); | 
                                                        |
| 100 | + echo "Publishing " . $page->Title . "\n";  | 
                                                        |
| 101 | +			$page->publish('Stage', 'Live'); | 
                                                        |
| 102 | 102 | }  | 
                                                        
| 103 | 103 | }  | 
                                                        
| 104 | 104 | |
| 105 | 105 | |
| 106 | 106 |  	public function generateAssertionsFromArray($toAssert) { | 
                                                        
| 107 | -		echo '$expected = array('."\n"; | 
                                                        |
| 108 | -		foreach ($toAssert as $key => $value) { | 
                                                        |
| 107 | +		echo '$expected = array(' . "\n"; | 
                                                        |
| 108 | +		foreach($toAssert as $key => $value) { | 
                                                        |
| 109 | 109 |  			$escValue = str_replace("'", '\\\'', $value); | 
                                                        
| 110 | 110 | echo "'$key' => '$escValue',\n";  | 
                                                        
| 111 | 111 | }  | 
                                                        
| 112 | 112 | echo ");\n";  | 
                                                        
| 113 | - echo '$this->assertEquals($expected, $somevar);'."\n";  | 
                                                        |
| 113 | + echo '$this->assertEquals($expected, $somevar);' . "\n";  | 
                                                        |
| 114 | 114 | }  | 
                                                        
| 115 | 115 | |
| 116 | 116 | |
| 117 | 117 |  	public function generateAssertionsFromArray1D($toAssert) { | 
                                                        
| 118 | -		echo '$expected = array('."\n"; | 
                                                        |
| 119 | -		foreach ($toAssert as $key => $value) { | 
                                                        |
| 118 | +		echo '$expected = array(' . "\n"; | 
                                                        |
| 119 | +		foreach($toAssert as $key => $value) { | 
                                                        |
| 120 | 120 |  			$escValue = str_replace("'", '\\\'', $value); | 
                                                        
| 121 | 121 | echo "'$escValue',";  | 
                                                        
| 122 | 122 | }  | 
                                                        
| 123 | 123 | echo ");\n";  | 
                                                        
| 124 | - echo '$this->assertEquals($expected, $somevar);'."\n";  | 
                                                        |
| 124 | + echo '$this->assertEquals($expected, $somevar);' . "\n";  | 
                                                        |
| 125 | 125 | }  | 
                                                        
| 126 | 126 | |
| 127 | 127 | |
| 128 | 128 |  	public function generateAssertionsFromArrayRecurse($toAssert) { | 
                                                        
| 129 | 129 | echo '$expected = ';  | 
                                                        
| 130 | - $this->recurseArrayAssertion($toAssert,1, 'FIXME');  | 
                                                        |
| 131 | - echo '$this->assertEquals($expected, $somevar);'."\n";  | 
                                                        |
| 130 | + $this->recurseArrayAssertion($toAssert, 1, 'FIXME');  | 
                                                        |
| 131 | + echo '$this->assertEquals($expected, $somevar);' . "\n";  | 
                                                        |
| 132 | 132 | }  | 
                                                        
| 133 | 133 | |
| 134 | 134 | |
| 135 | 135 |  	private function recurseArrayAssertion($toAssert, $depth, $parentKey) { | 
                                                        
| 136 | -		$prefix = str_repeat("\t",$depth); | 
                                                        |
| 136 | +		$prefix = str_repeat("\t", $depth); | 
                                                        |
| 137 | 137 |  		echo "\t{$prefix}'$parentKey' => array(\n"; | 
                                                        
| 138 | 138 | $ctr = 0;  | 
                                                        
| 139 | 139 | $len = sizeof(array_keys($toAssert));  | 
                                                        
| 140 | -		foreach ($toAssert as $key => $value) { | 
                                                        |
| 141 | -			if (is_array($value)) { | 
                                                        |
| 142 | - $this->recurseArrayAssertion($value, $depth+1, $key);  | 
                                                        |
| 140 | +		foreach($toAssert as $key => $value) { | 
                                                        |
| 141 | +			if(is_array($value)) { | 
                                                        |
| 142 | + $this->recurseArrayAssertion($value, $depth + 1, $key);  | 
                                                        |
| 143 | 143 |  			} else { | 
                                                        
| 144 | 144 |  				$escValue = str_replace("'", '\\\'', $value); | 
                                                        
| 145 | 145 | $comma = ',';  | 
                                                        
| 146 | -				if ($ctr == $len-1) { | 
                                                        |
| 146 | +				if($ctr == $len - 1) { | 
                                                        |
| 147 | 147 | $comma = '';  | 
                                                        
| 148 | 148 | }  | 
                                                        
| 149 | 149 | echo "\t\t$prefix'$key' => '$escValue'$comma\n";  | 
                                                        
@@ -173,7 +173,7 @@ discard block  | 
                                                    ||
| 173 | 173 | $nameToCheck = end($splits);  | 
                                                        
| 174 | 174 | echo "NAME TO CHECK:$nameToCheck\n";  | 
                                                        
| 175 | 175 | $this->assertEquals($actualTabName, $nameToCheck);  | 
                                                        
| 176 | -		if ($size == 1) { | 
                                                        |
| 176 | +		if($size == 1) { | 
                                                        |
| 177 | 177 |  			$this->assertEquals("Root_${tabName}", $tab->id()); | 
                                                        
| 178 | 178 |  		} else { | 
                                                        
| 179 | 179 |  			$expected = "Root_{$splits[0]}_set_{$splits[1]}"; | 
                                                        
@@ -184,11 +184,11 @@ discard block  | 
                                                    ||
| 184 | 184 | }  | 
                                                        
| 185 | 185 | |
| 186 | 186 | |
| 187 | -	public function checkFieldExists($tab,$fieldName) { | 
                                                        |
| 187 | +	public function checkFieldExists($tab, $fieldName) { | 
                                                        |
| 188 | 188 | $fields = $tab->Fields();  | 
                                                        
| 189 | 189 |  		echo "TAB:{$tab->Name}\n"; | 
                                                        
| 190 | -		foreach ($fields as $fi) { | 
                                                        |
| 191 | - echo "NAME:".$fi->Name."\n";  | 
                                                        |
| 190 | +		foreach($fields as $fi) { | 
                                                        |
| 191 | + echo "NAME:" . $fi->Name . "\n";  | 
                                                        |
| 192 | 192 | }  | 
                                                        
| 193 | 193 | $field = $tab->fieldByName($fieldName);  | 
                                                        
| 194 | 194 | $this->assertTrue($field != null);  | 
                                                        
@@ -221,11 +221,11 @@ discard block  | 
                                                    ||
| 221 | 221 | $status = $index->getStatus()->getData();  | 
                                                        
| 222 | 222 | |
| 223 | 223 | $numberDocsInIndex = -1; // flag value for not yet indexed  | 
                                                        
| 224 | -		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { | 
                                                        |
| 224 | +		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { | 
                                                        |
| 225 | 225 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];  | 
                                                        
| 226 | 226 | }  | 
                                                        
| 227 | 227 | |
| 228 | - $this->assertEquals($expectedAmount,$numberDocsInIndex);  | 
                                                        |
| 228 | + $this->assertEquals($expectedAmount, $numberDocsInIndex);  | 
                                                        |
| 229 | 229 | }  | 
                                                        
| 230 | 230 | |
| 231 | 231 | /*  | 
                                                        
@@ -236,7 +236,7 @@ discard block  | 
                                                    ||
| 236 | 236 | $status = $index->getStatus()->getData();  | 
                                                        
| 237 | 237 | |
| 238 | 238 | $numberDocsInIndex = -1; // flag value for not yet indexed  | 
                                                        
| 239 | -		if (isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { | 
                                                        |
| 239 | +		if(isset($status['indices']['elastica_ss_module_test_en_us']['docs'])) { | 
                                                        |
| 240 | 240 | $numberDocsInIndex = $status['indices']['elastica_ss_module_test_en_us']['docs']['num_docs'];  | 
                                                        
| 241 | 241 | }  | 
                                                        
| 242 | 242 | |
@@ -282,7 +282,6 @@ discard block  | 
                                                    ||
| 282 | 282 | * to "auto-filter" all SELECT queries by this language.  | 
                                                        
| 283 | 283 |  	 * See {@link disable_locale_filter()} on how to override this behaviour temporarily. | 
                                                        
| 284 | 284 | *  | 
                                                        
| 285 | - * @param string $lang New reading language.  | 
                                                        |
| 286 | 285 | */  | 
                                                        
| 287 | 286 |  	static function set_current_locale($locale) { | 
                                                        
| 288 | 287 | self::$current_locale = $locale;  | 
                                                        
@@ -373,7 +372,7 @@ discard block  | 
                                                    ||
| 373 | 372 | * Check if a given SQLQuery filters on the Locale field  | 
                                                        
| 374 | 373 | *  | 
                                                        
| 375 | 374 | * @param SQLQuery $query  | 
                                                        
| 376 | - * @return boolean  | 
                                                        |
| 375 | + * @return boolean|null  | 
                                                        |
| 377 | 376 | */  | 
                                                        
| 378 | 377 |  	protected function filtersOnLocale($query) { | 
                                                        
| 379 | 378 |  		foreach($query->getWhere() as $condition) { | 
                                                        
@@ -536,7 +535,7 @@ discard block  | 
                                                    ||
| 536 | 535 | * This ID might equal the record ID, but doesn't have to -  | 
                                                        
| 537 | 536 | * it just points to one "original" record in the list.  | 
                                                        
| 538 | 537 | *  | 
                                                        
| 539 | - * @return int Numeric ID of the translationgroup in the <classname>_translationgroup table  | 
                                                        |
| 538 | + * @return false|string Numeric ID of the translationgroup in the <classname>_translationgroup table  | 
                                                        |
| 540 | 539 | */  | 
                                                        
| 541 | 540 |  	public function getTranslationGroup() { | 
                                                        
| 542 | 541 | if(!$this->owner->exists()) return false;  | 
                                                        
@@ -892,7 +892,7 @@  | 
                                                    ||
| 892 | 892 | * to Translatable  | 
                                                        
| 893 | 893 | *  | 
                                                        
| 894 | 894 | * @return bool  | 
                                                        
| 895 | - */  | 
                                                        |
| 895 | + */  | 
                                                        |
| 896 | 896 |  	public function augmentValidURLSegment() { | 
                                                        
| 897 | 897 | $reEnableFilter = false;  | 
                                                        
| 898 | 898 |  		if(!Config::inst()->get('Translatable', 'enforce_global_unique_urls')) { | 
                                                        
@@ -377,7 +377,9 @@ discard block  | 
                                                    ||
| 377 | 377 | */  | 
                                                        
| 378 | 378 |  	protected function filtersOnLocale($query) { | 
                                                        
| 379 | 379 |  		foreach($query->getWhere() as $condition) { | 
                                                        
| 380 | -			if(preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) return true; | 
                                                        |
| 380 | +			if(preg_match('/("|\'|`)Locale("|\'|`)/', $condition)) { | 
                                                        |
| 381 | + return true;  | 
                                                        |
| 382 | + }  | 
                                                        |
| 381 | 383 | }  | 
                                                        
| 382 | 384 | }  | 
                                                        
| 383 | 385 | |
@@ -429,7 +431,9 @@ discard block  | 
                                                    ||
| 429 | 431 | // FIXME - NO TEST COVERAGE BUT REQUIRED  | 
                                                        
| 430 | 432 |  	function augmentDatabase() { | 
                                                        
| 431 | 433 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class);  | 
                                                        
| 432 | - if($this->owner->class != $baseDataClass) return;  | 
                                                        |
| 434 | +		if($this->owner->class != $baseDataClass) { | 
                                                        |
| 435 | + return;  | 
                                                        |
| 436 | + }  | 
                                                        |
| 433 | 437 | |
| 434 | 438 | $fields = array(  | 
                                                        
| 435 | 439 | 'OriginalID' => 'Int',  | 
                                                        
@@ -456,7 +460,9 @@ discard block  | 
                                                    ||
| 456 | 460 | */  | 
                                                        
| 457 | 461 |  	public function requireDefaultRecords() { | 
                                                        
| 458 | 462 | // @todo This relies on the Locale attribute being on the base data class, and not any subclasses  | 
                                                        
| 459 | - if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) return false;  | 
                                                        |
| 463 | +		if($this->owner->class != ClassInfo::baseDataClass($this->owner->class)) { | 
                                                        |
| 464 | + return false;  | 
                                                        |
| 465 | + }  | 
                                                        |
| 460 | 466 | |
| 461 | 467 | // Permissions: If a group doesn't have any specific TRANSLATE_<locale> edit rights,  | 
                                                        
| 462 | 468 | // but has CMS_ACCESS_CMSMain (general CMS access), then assign TRANSLATE_ALL permissions as a default.  | 
                                                        
@@ -468,14 +474,20 @@ discard block  | 
                                                    ||
| 468 | 474 | 'CMS_ACCESS_LeftAndMain',  | 
                                                        
| 469 | 475 | 'ADMIN'  | 
                                                        
| 470 | 476 | ));  | 
                                                        
| 471 | -		if($groups) foreach($groups as $group) { | 
                                                        |
| 477 | +		if($groups) { | 
                                                        |
| 478 | +			foreach($groups as $group) { | 
                                                        |
| 472 | 479 |  			$codes = $group->Permissions()->column('Code'); | 
                                                        
| 480 | + }  | 
                                                        |
| 473 | 481 | $hasTranslationCode = false;  | 
                                                        
| 474 | 482 |  			foreach($codes as $code) { | 
                                                        
| 475 | -				if(preg_match('/^TRANSLATE_/', $code)) $hasTranslationCode = true; | 
                                                        |
| 483 | +				if(preg_match('/^TRANSLATE_/', $code)) { | 
                                                        |
| 484 | + $hasTranslationCode = true;  | 
                                                        |
| 485 | + }  | 
                                                        |
| 476 | 486 | }  | 
                                                        
| 477 | 487 | // Only add the code if no more restrictive code exists  | 
                                                        
| 478 | - if(!$hasTranslationCode) Permission::grant($group->ID, 'TRANSLATE_ALL');  | 
                                                        |
| 488 | +			if(!$hasTranslationCode) { | 
                                                        |
| 489 | + Permission::grant($group->ID, 'TRANSLATE_ALL');  | 
                                                        |
| 490 | + }  | 
                                                        |
| 479 | 491 | }  | 
                                                        
| 480 | 492 | |
| 481 | 493 | // If the Translatable extension was added after the first records were already  | 
                                                        
@@ -485,7 +497,9 @@ discard block  | 
                                                    ||
| 485 | 497 | 'SELECT "ID" FROM "%s" WHERE "Locale" IS NULL OR "Locale" = \'\'',  | 
                                                        
| 486 | 498 | ClassInfo::baseDataClass($this->owner->class)  | 
                                                        
| 487 | 499 | ))->column();  | 
                                                        
| 488 | - if(!$idsWithoutLocale) return;  | 
                                                        |
| 500 | +		if(!$idsWithoutLocale) { | 
                                                        |
| 501 | + return;  | 
                                                        |
| 502 | + }  | 
                                                        |
| 489 | 503 | |
| 490 | 504 | |
| 491 | 505 | |
@@ -502,7 +516,9 @@ discard block  | 
                                                    ||
| 502 | 516 | * @param boolean $overwrite  | 
                                                        
| 503 | 517 | */  | 
                                                        
| 504 | 518 |  	public function addTranslationGroup($originalID, $overwrite = false) { | 
                                                        
| 505 | - if(!$this->owner->exists()) return false;  | 
                                                        |
| 519 | +		if(!$this->owner->exists()) { | 
                                                        |
| 520 | + return false;  | 
                                                        |
| 521 | + }  | 
                                                        |
| 506 | 522 | |
| 507 | 523 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class);  | 
                                                        
| 508 | 524 | $existingGroupID = $this->getTranslationGroup($originalID);  | 
                                                        
@@ -539,7 +555,9 @@ discard block  | 
                                                    ||
| 539 | 555 | * @return int Numeric ID of the translationgroup in the <classname>_translationgroup table  | 
                                                        
| 540 | 556 | */  | 
                                                        
| 541 | 557 |  	public function getTranslationGroup() { | 
                                                        
| 542 | - if(!$this->owner->exists()) return false;  | 
                                                        |
| 558 | +		if(!$this->owner->exists()) { | 
                                                        |
| 559 | + return false;  | 
                                                        |
| 560 | + }  | 
                                                        |
| 543 | 561 | |
| 544 | 562 | $baseDataClass = ClassInfo::baseDataClass($this->owner->class);  | 
                                                        
| 545 | 563 | return DB::query(  | 
                                                        
@@ -646,8 +664,10 @@ discard block  | 
                                                    ||
| 646 | 664 | $this->owner->ClassName = $changedFields['ClassName']['before'];  | 
                                                        
| 647 | 665 | $translations = $this->owner->getTranslations();  | 
                                                        
| 648 | 666 | $this->owner->ClassName = $changedFields['ClassName']['after'];  | 
                                                        
| 649 | -				if($translations) foreach($translations as $translation) { | 
                                                        |
| 667 | +				if($translations) { | 
                                                        |
| 668 | +					foreach($translations as $translation) { | 
                                                        |
| 650 | 669 | $translation->setClassName($this->owner->ClassName);  | 
                                                        
| 670 | + }  | 
                                                        |
| 651 | 671 | $translation = $translation->newClassInstance($translation->ClassName);  | 
                                                        
| 652 | 672 | $translation->populateDefaults();  | 
                                                        
| 653 | 673 | $translation->forceChange();  | 
                                                        
@@ -745,7 +765,9 @@ discard block  | 
                                                    ||
| 745 | 765 | * @return DataObjectSet  | 
                                                        
| 746 | 766 | */  | 
                                                        
| 747 | 767 |  	function getTranslations($locale = null, $stage = null) { | 
                                                        
| 748 | - if(!$this->owner->exists()) return new ArrayList();  | 
                                                        |
| 768 | +		if(!$this->owner->exists()) { | 
                                                        |
| 769 | + return new ArrayList();  | 
                                                        |
| 770 | + }  | 
                                                        |
| 749 | 771 | |
| 750 | 772 | // HACK need to disable language filtering in augmentSQL(),  | 
                                                        
| 751 | 773 | // as we purposely want to get different language  | 
                                                        
@@ -770,14 +792,18 @@ discard block  | 
                                                    ||
| 770 | 792 | $currentStage = Versioned::current_stage();  | 
                                                        
| 771 | 793 |  		$joinOnClause = sprintf('"%s_translationgroups"."OriginalID" = "%s"."ID"', $baseDataClass, $baseDataClass); | 
                                                        
| 772 | 794 |  		if($this->owner->hasExtension("Versioned")) { | 
                                                        
| 773 | - if($stage) Versioned::reading_stage($stage);  | 
                                                        |
| 795 | +			if($stage) { | 
                                                        |
| 796 | + Versioned::reading_stage($stage);  | 
                                                        |
| 797 | + }  | 
                                                        |
| 774 | 798 | $translations = Versioned::get_by_stage(  | 
                                                        
| 775 | 799 | $baseDataClass,  | 
                                                        
| 776 | 800 | Versioned::current_stage(),  | 
                                                        
| 777 | 801 | $filter,  | 
                                                        
| 778 | 802 | null  | 
                                                        
| 779 | 803 |  			)->leftJoin("{$baseDataClass}_translationgroups", $joinOnClause); | 
                                                        
| 780 | - if($stage) Versioned::reading_stage($currentStage);  | 
                                                        |
| 804 | +			if($stage) { | 
                                                        |
| 805 | + Versioned::reading_stage($currentStage);  | 
                                                        |
| 806 | + }  | 
                                                        |
| 781 | 807 |  		} else { | 
                                                        
| 782 | 808 | $class = $this->owner->class;  | 
                                                        
| 783 | 809 | $translations = $baseDataClass::get()  | 
                                                        
@@ -861,7 +887,9 @@ discard block  | 
                                                    ||
| 861 | 887 | self::set_current_locale($originalLocale);  | 
                                                        
| 862 | 888 | |
| 863 | 889 |  		if($original) { | 
                                                        
| 864 | - if($translation = $original->getTranslation($locale)) return trim($translation->RelativeLink(true), '/');  | 
                                                        |
| 890 | +			if($translation = $original->getTranslation($locale)) { | 
                                                        |
| 891 | + return trim($translation->RelativeLink(true), '/');  | 
                                                        |
| 892 | + }  | 
                                                        |
| 865 | 893 | }  | 
                                                        
| 866 | 894 | }  | 
                                                        
| 867 | 895 | |
@@ -916,7 +944,9 @@ discard block  | 
                                                    ||
| 916 | 944 | $existingPage = SiteTree::get()  | 
                                                        
| 917 | 945 | // disable get_one cache, as this otherwise may pick up results from when locale_filter was on  | 
                                                        
| 918 | 946 |  			->where("\"URLSegment\" = '{$this->owner->URLSegment}' $IDFilter $parentFilter")->First(); | 
                                                        
| 919 | - if($reEnableFilter) self::enable_locale_filter();  | 
                                                        |
| 947 | +		if($reEnableFilter) { | 
                                                        |
| 948 | + self::enable_locale_filter();  | 
                                                        |
| 949 | + }  | 
                                                        |
| 920 | 950 | |
| 921 | 951 | // By returning TRUE or FALSE, we overrule the base SiteTree->validateURLSegment() logic  | 
                                                        
| 922 | 952 | return !$existingPage;  | 
                                                        
@@ -304,7 +304,7 @@ discard block  | 
                                                    ||
| 304 | 304 |  	 * @param $enabled (default true), if false this call is a no-op - see {@link disable_locale_filter()} | 
                                                        
| 305 | 305 | */  | 
                                                        
| 306 | 306 |  	public static function enable_locale_filter($enabled = true) { | 
                                                        
| 307 | -		if ($enabled) { | 
                                                        |
| 307 | +		if($enabled) { | 
                                                        |
| 308 | 308 | self::$locale_filter_enabled = true;  | 
                                                        
| 309 | 309 | }  | 
                                                        
| 310 | 310 | }  | 
                                                        
@@ -350,8 +350,8 @@ discard block  | 
                                                    ||
| 350 | 350 | array_keys($this->owner->has_many()),  | 
                                                        
| 351 | 351 | array_keys($this->owner->many_many())  | 
                                                        
| 352 | 352 | );  | 
                                                        
| 353 | -			foreach (array_keys($this->owner->has_one()) as $fieldname) { | 
                                                        |
| 354 | - $this->translatableFields[] = $fieldname.'ID';  | 
                                                        |
| 353 | +			foreach(array_keys($this->owner->has_one()) as $fieldname) { | 
                                                        |
| 354 | + $this->translatableFields[] = $fieldname . 'ID';  | 
                                                        |
| 355 | 355 | }  | 
                                                        
| 356 | 356 | }  | 
                                                        
| 357 | 357 | }  | 
                                                        
@@ -389,7 +389,7 @@ discard block  | 
                                                    ||
| 389 | 389 | *  | 
                                                        
| 390 | 390 |  	 * Use {@link disable_locale_filter()} to temporarily disable this "auto-filtering". | 
                                                        
| 391 | 391 | */  | 
                                                        
| 392 | -	public function augmentSQL(SQLQuery &$query, DataQuery $dataQuery = null) { | 
                                                        |
| 392 | +	public function augmentSQL(SQLQuery & $query, DataQuery $dataQuery = null) { | 
                                                        |
| 393 | 393 | // If the record is saved (and not a singleton), and has a locale,  | 
                                                        
| 394 | 394 | // limit the current call to its locale. This fixes a lot of problems  | 
                                                        
| 395 | 395 | // with other extensions like Versioned  | 
                                                        
@@ -415,13 +415,13 @@ discard block  | 
                                                    ||
| 415 | 415 | // call or through custom SQL filters)  | 
                                                        
| 416 | 416 | && !$this->filtersOnLocale($query)  | 
                                                        
| 417 | 417 | //&& !$query->filtersOnFK()  | 
                                                        
| 418 | -		)  { | 
                                                        |
| 418 | +		) { | 
                                                        |
| 419 | 419 |  			$qry = sprintf('"%s"."Locale" = \'%s\'', $baseTable, Convert::raw2sql($locale)); | 
                                                        
| 420 | 420 | $query->addWhere($qry);  | 
                                                        
| 421 | 421 | }  | 
                                                        
| 422 | 422 | }  | 
                                                        
| 423 | 423 | |
| 424 | -	function augmentDataQueryCreation(SQLQuery &$sqlQuery, DataQuery &$dataQuery) { | 
                                                        |
| 424 | +	function augmentDataQueryCreation(SQLQuery & $sqlQuery, DataQuery & $dataQuery) { | 
                                                        |
| 425 | 425 | $enabled = self::locale_filter_enabled();  | 
                                                        
| 426 | 426 | $dataQuery->setQueryParam(self::QUERY_LOCALE_FILTER_ENABLED, $enabled);  | 
                                                        
| 427 | 427 | }  | 
                                                        
@@ -618,7 +618,7 @@ discard block  | 
                                                    ||
| 618 | 618 | $changedFields = $this->owner->getChangedFields();  | 
                                                        
| 619 | 619 | $changed = isset($changedFields['ClassName']);  | 
                                                        
| 620 | 620 | |
| 621 | -			if ($changed && $this->owner->hasExtension('Versioned')) { | 
                                                        |
| 621 | +			if($changed && $this->owner->hasExtension('Versioned')) { | 
                                                        |
| 622 | 622 | // this is required because when publishing a node the before/after  | 
                                                        
| 623 | 623 | // values of $changedFields['ClassName'] will be the same because  | 
                                                        
| 624 | 624 | // the record was already written to the stage/draft table and thus  | 
                                                        
@@ -637,7 +637,7 @@ discard block  | 
                                                    ||
| 637 | 637 | '"ID" = ' . $this->owner->ID,  | 
                                                        
| 638 | 638 | null  | 
                                                        
| 639 | 639 | );  | 
                                                        
| 640 | -				if ($fresh) { | 
                                                        |
| 640 | +				if($fresh) { | 
                                                        |
| 641 | 641 | $changed = $changedFields['ClassName']['after'] != $fresh->ClassName;  | 
                                                        
| 642 | 642 | }  | 
                                                        
| 643 | 643 | }  | 
                                                        
@@ -694,7 +694,7 @@ discard block  | 
                                                    ||
| 694 | 694 | // If the parentID value has come from a translated page,  | 
                                                        
| 695 | 695 | // then we need to find the corresponding parentID value  | 
                                                        
| 696 | 696 | // in the default Locale.  | 
                                                        
| 697 | - if (  | 
                                                        |
| 697 | + if(  | 
                                                        |
| 698 | 698 | is_int($parentID)  | 
                                                        
| 699 | 699 | && $parentID > 0  | 
                                                        
| 700 | 700 |  			&& ($parent = DataObject::get_by_id('SiteTree', $parentID)) | 
                                                        
@@ -705,7 +705,7 @@ discard block  | 
                                                    ||
| 705 | 705 | |
| 706 | 706 | // Find the locale language-independent of the page  | 
                                                        
| 707 | 707 | self::disable_locale_filter();  | 
                                                        
| 708 | - $default = SiteTree::get()->where(sprintf (  | 
                                                        |
| 708 | + $default = SiteTree::get()->where(sprintf(  | 
                                                        |
| 709 | 709 | '"URLSegment" = \'%s\'%s',  | 
                                                        
| 710 | 710 | Convert::raw2sql($URLSegment),  | 
                                                        
| 711 | 711 | (is_int($parentID) ? " AND \"ParentID\" = $parentID" : null)  | 
                                                        
@@ -721,7 +721,7 @@ discard block  | 
                                                    ||
| 721 | 721 |  	public function updateRelativeLink(&$base, &$action) { | 
                                                        
| 722 | 722 | // Prevent home pages for non-default locales having their urlsegments  | 
                                                        
| 723 | 723 | // reduced to the site root.  | 
                                                        
| 724 | -		if($base === null && $this->owner->Locale != self::default_locale()){ | 
                                                        |
| 724 | +		if($base === null && $this->owner->Locale != self::default_locale()) { | 
                                                        |
| 725 | 725 | $base = $this->owner->URLSegment;  | 
                                                        
| 726 | 726 | }  | 
                                                        
| 727 | 727 | }  | 
                                                        
@@ -827,7 +827,7 @@ discard block  | 
                                                    ||
| 827 | 827 | */  | 
                                                        
| 828 | 828 |  	static function get_existing_content_languages($className = 'SiteTree', $where = '') { | 
                                                        
| 829 | 829 | $baseTable = ClassInfo::baseDataClass($className);  | 
                                                        
| 830 | -		$query = new SQLQuery("Distinct \"Locale\"","\"$baseTable\"",$where, '', "\"Locale\""); | 
                                                        |
| 830 | +		$query = new SQLQuery("Distinct \"Locale\"", "\"$baseTable\"", $where, '', "\"Locale\""); | 
                                                        |
| 831 | 831 | $dbLangs = $query->execute()->column();  | 
                                                        
| 832 | 832 | $langlist = array_merge((array)Translatable::default_locale(), (array)$dbLangs);  | 
                                                        
| 833 | 833 | $returnMap = array();  | 
                                                        
@@ -835,7 +835,7 @@ discard block  | 
                                                    ||
| 835 | 835 |  			Config::inst()->get('i18n', 'all_locales'), | 
                                                        
| 836 | 836 |  			Config::inst()->get('i18n', 'common_locales') | 
                                                        
| 837 | 837 | );  | 
                                                        
| 838 | -		foreach ($langlist as $langCode) { | 
                                                        |
| 838 | +		foreach($langlist as $langCode) { | 
                                                        |
| 839 | 839 |  			if($langCode && isset($allCodes[$langCode])) { | 
                                                        
| 840 | 840 |  				if(is_array($allCodes[$langCode])) { | 
                                                        
| 841 | 841 | $returnMap[$langCode] = $allCodes[$langCode]['name'];  | 
                                                        
@@ -870,7 +870,7 @@ discard block  | 
                                                    ||
| 870 | 870 |  	 * @deprecated 2.4 Use {@link Translatable::get_homepage_link_by_locale()} | 
                                                        
| 871 | 871 | */  | 
                                                        
| 872 | 872 |  	static function get_homepage_urlsegment_by_locale($locale) { | 
                                                        
| 873 | - user_error (  | 
                                                        |
| 873 | + user_error(  | 
                                                        |
| 874 | 874 | 'Translatable::get_homepage_urlsegment_by_locale() is deprecated, please use get_homepage_link_by_locale()',  | 
                                                        
| 875 | 875 | E_USER_NOTICE  | 
                                                        
| 876 | 876 | );  | 
                                                        
@@ -884,7 +884,7 @@ discard block  | 
                                                    ||
| 884 | 884 | * Return a piece of text to keep DataObject cache keys appropriately specific  | 
                                                        
| 885 | 885 | */  | 
                                                        
| 886 | 886 |  	function cacheKeyComponent() { | 
                                                        
| 887 | - return 'locale-'.self::get_current_locale();  | 
                                                        |
| 887 | + return 'locale-' . self::get_current_locale();  | 
                                                        |
| 888 | 888 | }  | 
                                                        
| 889 | 889 | |
| 890 | 890 | /**  | 
                                                        
@@ -902,10 +902,10 @@ discard block  | 
                                                    ||
| 902 | 902 | $reEnableFilter = true;  | 
                                                        
| 903 | 903 | }  | 
                                                        
| 904 | 904 | |
| 905 | -		$IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" :  null; | 
                                                        |
| 905 | +		$IDFilter = ($this->owner->ID) ? "AND \"SiteTree\".\"ID\" <> {$this->owner->ID}" : null; | 
                                                        |
| 906 | 906 | $parentFilter = null;  | 
                                                        
| 907 | 907 | |
| 908 | -		if (Config::inst()->get('SiteTree', 'nested_urls')) { | 
                                                        |
| 908 | +		if(Config::inst()->get('SiteTree', 'nested_urls')) { | 
                                                        |
| 909 | 909 |  			if($this->owner->ParentID) { | 
                                                        
| 910 | 910 |  				$parentFilter = " AND \"SiteTree\".\"ParentID\" = {$this->owner->ParentID}"; | 
                                                        
| 911 | 911 |  			} else { | 
                                                        
@@ -479,6 +479,9 @@  | 
                                                    ||
| 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);  | 
                                                        
@@ -140,7 +140,7 @@  | 
                                                    ||
| 140 | 140 | |
| 141 | 141 |  	public function testEach() { | 
                                                        
| 142 | 142 |  		$callback = function($fp) { | 
                                                        
| 143 | - $this->assertTrue(true, 'Callback reached');  | 
                                                        |
| 143 | + $this->assertTrue(true, 'Callback reached');  | 
                                                        |
| 144 | 144 | };  | 
                                                        
| 145 | 145 |  		$resultList = $this->getResultsFor('New Zealand',10); | 
                                                        
| 146 | 146 | $resultList->each($callback);  |