1<?php 2 3abstract class Search_Index_NumericTest extends PHPUnit_Framework_TestCase 4{ 5 protected $index; 6 7 protected function populate($index) 8 { 9 $typeFactory = $index->getTypeFactory(); 10 $index->addDocument( 11 [ 12 'object_type' => $typeFactory->identifier('wiki page'), 13 'object_id' => $typeFactory->identifier('HomePage'), 14 'contents' => $typeFactory->plaintext('module 7, 2.5.3')->filter( 15 [ 16 new Search_ContentFilter_VersionNumber, 17 ] 18 ), 19 ] 20 ); 21 } 22 23 function testMatchVersion() 24 { 25 $this->assertResultCount(1, '2.5.3'); 26 } 27 28 function testNoMatchLesserVersionPortion() 29 { 30 $this->assertResultCount(0, '5.3'); 31 } 32 33 function testMatchHigherVersionPortion() 34 { 35 $this->assertResultCount(1, '2.5'); 36 } 37 38 private function assertResultCount($count, $argument) 39 { 40 $query = new Search_Query; 41 $query->filterContent($argument); 42 43 $this->assertEquals($count, count($query->search($this->index))); 44 } 45} 46