public function testGetExpressionData() { $subject = new Expression('? = ?', array(33.0, true)); $this->expr->setSubject($subject); $this->platform->enableFloatConversion(false); $this->assertSame(array(array('%s = %s', array(33.0, 1), array(Expression::TYPE_VALUE, Expression::TYPE_VALUE))), $this->expr->getExpressionData()); $platform = new TrustedSphinxQL(); // Use platform to ensure same float point precision $platform->enableFloatConversion(true); $this->platform->enableFloatConversion(true); $this->assertSame(array(array('%s = %s', array($platform->quoteTrustedValue(33.0), 1), array(Expression::TYPE_LITERAL, Expression::TYPE_VALUE))), $this->expr->getExpressionData()); }
public function testFloatConversion() { //assume default enabled $this->assertTrue($this->platform->isFloatConversionEnabled()); $this->assertInstanceOf('\\SphinxSearch\\Db\\Adapter\\Platform\\SphinxQL', $this->platform->enableFloatConversion(false)); $this->assertFalse($this->platform->isFloatConversionEnabled()); $this->platform->enableFloatConversion(true); $this->assertTrue($this->platform->isFloatConversionEnabled()); //test default param value in method $this->platform->enableFloatConversion(); $this->assertTrue($this->platform->isFloatConversionEnabled()); $singlePrecisionPi = '3.141592654'; $doublePrecisionPi = '3.1415926535898'; $this->assertSame($singlePrecisionPi, $this->platform->toFloatSinglePrecision(pi())); $this->platform->enableFloatConversion(false); $this->assertSame($doublePrecisionPi, $this->platform->quoteTrustedValue(pi())); $this->platform->enableFloatConversion(true); $this->assertSame($singlePrecisionPi, $this->platform->quoteTrustedValue(pi())); }