Exemple #1
0
 public function testTostring()
 {
     $oGroup = new Sequin\Query(new Sequin\Term('foo'));
     $oGroup->andRight(new Sequin\Term('bar'));
     $this->assertEquals('(foo) AND bar', $oGroup->toString());
     $oLeftTerm = new Sequin\Term('foo');
     $oLeftTerm->andRight(new Sequin\Term('bar'));
     $oGroup = new Sequin\Query($oLeftTerm);
     $oGroup->orRight(new Sequin\Term('baz'));
     $this->assertEquals('(foo AND bar) OR baz', $oGroup->toString());
     $oLeftTerm = new Sequin\Term('foo');
     $oLeftTerm->andRight(new Sequin\Term('bar'));
     $oGroup = new Sequin\Query($oLeftTerm, 'fieldName', 3);
     $oGroup->orRight(new Sequin\Term('baz'));
     $this->assertEquals('fieldName:(foo AND bar)^3 OR baz', $oGroup->toString());
 }
Exemple #2
0
 public function testNewinstanceCreatesANewInstance()
 {
     $oTerm = Sequin\Term::newInstance('value');
     $this->assertTrue($oTerm instanceof Sequin\Term);
     $this->assertEquals('value', $oTerm->value());
     $this->assertNull($oTerm->fieldName());
     $this->assertEquals(1, $oTerm->boostFactor());
     $oTerm = Sequin\Term::newInstance('value', 'fieldName');
     $this->assertTrue($oTerm instanceof Sequin\Term);
     $this->assertEquals('value', $oTerm->value());
     $this->assertEquals('fieldName', $oTerm->fieldName());
     $this->assertEquals(1, $oTerm->boostFactor());
     $oTerm = Sequin\Term::newInstance('value', 'fieldName', 3);
     $this->assertTrue($oTerm instanceof Sequin\Term);
     $this->assertEquals('value', $oTerm->value());
     $this->assertEquals('fieldName', $oTerm->fieldName());
     $this->assertEquals(3, $oTerm->boostFactor());
 }