/** * @return string */ protected function getRootNamespace() { $rootClassReflection = new \ReflectionClass(FloatObject::getClass()); return $rootClassReflection->getNamespaceName(); }
/** * @test * @expectedException \Granam\Float\Tools\Exceptions\ValueLostOnCast * @dataProvider provideStrictness * @param bool $strict */ public function I_can_force_exception_in_case_of_rounding($strict) { try { $floatObject = new FloatObject($floatValue = '123456.999', $strict, true); self::assertSame((double) $floatValue, $floatObject->getValue()); } catch (\Exception $exception) { self::fail('Unexpected any exception here: ' . $exception->getMessage()); } new FloatObject('123456.999999999999999999999999999999999999', $strict, true); self::fail('Rounding has not been detected'); }
/** * @test */ public function I_can_use_it_same_way_as_using_number_object() { $this->I_can_use_it_same_way_as_using('toFloat', FloatObject::getClass()); $this->I_can_use_it_same_way_as_using('toPositiveFloat', PositiveFloatObject::getClass()); $this->I_can_use_it_same_way_as_using('toNegativeFloat', NegativeFloatObject::getClass()); }