/** * Register the Converter. * * @return void */ protected function registerConverter() { $this->app['converter'] = $this->app->share(function ($app) { $measurements = $app['config']->get('cartalyst.converter.measurements'); $converter = new Converter($app['converter.exchanger']); $converter->setMeasurements($measurements); return $converter; }); }
/** * @test */ public function it_can_convert_weights() { // Grams to pounds $gLb = $this->converter->from('weight.g')->to('weight.lb')->convert(200000); $this->assertEquals($gLb->format(), '441 lb'); $this->assertEquals($gLb->getValue(), 440.924); // Pounds to kilograms $lbKg = $this->converter->from('weight.lb')->to('weight.kg')->convert(4440.924); $this->assertEquals($lbKg->format(), '2.014,37 KG'); $this->assertEquals(round($lbKg->getValue(), 2), 2014.37); }