public function test_number_to_word() { try { util::number_to_word('junk data'); $this->fail('Accepted junk data'); } catch (\LogicException $e) { $this->assertEquals('Not a number', $e->getMessage()); } // Partially numeric. $this->assertEquals('', util::number_to_word('1a')); // Decimals $this->assertEquals('five point zero five', util::number_to_word('5.05')); $this->assertEquals('zero point eight', util::number_to_word(0.8)); // Integers $this->assertEquals('positive one', util::number_to_word('+1')); $this->assertEquals('negative twelve', util::number_to_word(-12)); $this->assertEquals('one', util::number_to_word(1)); $this->assertEquals('five', util::number_to_word(5)); $this->assertEquals('fifteen', util::number_to_word(15)); $this->assertEquals('twenty-one', util::number_to_word(21)); $this->assertEquals('thirty-two', util::number_to_word(32)); $this->assertEquals('forty-three', util::number_to_word(43)); $this->assertEquals('fifty-four', util::number_to_word(54)); $this->assertEquals('sixty-six', util::number_to_word(66)); $this->assertEquals('seventy-seven', util::number_to_word(77)); $this->assertEquals('eighty-eight', util::number_to_word(88)); $this->assertEquals('ninety-nine', util::number_to_word(99)); $this->assertEquals('one hundred and thirty-six', util::number_to_word(136)); $this->assertEquals('ten', util::number_to_word(10)); $this->assertEquals('twenty', util::number_to_word(20)); $this->assertEquals('thirty', util::number_to_word(30)); $this->assertEquals('forty', util::number_to_word(40)); $this->assertEquals('fifty', util::number_to_word(50)); $this->assertEquals('sixty', util::number_to_word(60)); $this->assertEquals('seventy', util::number_to_word(70)); $this->assertEquals('eighty', util::number_to_word(80)); $this->assertEquals('ninety', util::number_to_word(90)); $this->assertEquals('eleven', util::number_to_word(11)); $this->assertEquals('thirteen', util::number_to_word(13)); $this->assertEquals('fourteen', util::number_to_word(14)); $this->assertEquals('fifteen', util::number_to_word(15)); $this->assertEquals('sixteen', util::number_to_word(16)); $this->assertEquals('seventeen', util::number_to_word(17)); $this->assertEquals('eighteen', util::number_to_word(18)); $this->assertEquals('nineteen', util::number_to_word(19)); $this->assertEquals('one thousand', util::number_to_word(1000)); $this->assertEquals('one million', util::number_to_word(1000000)); $this->assertEquals('one billion', util::number_to_word(1000000000)); $this->assertEquals('one trillion', util::number_to_word(1000000000000.0)); $this->assertEquals('one quadrillion', util::number_to_word('1000000000000000')); $this->assertEquals('one quintrillion', util::number_to_word('1000000000000000000')); $this->assertEquals('one sextillion', util::number_to_word('1000000000000000000000')); $this->assertEquals('one septillion', util::number_to_word('1000000000000000000000000')); $this->assertEquals('one octillion', util::number_to_word('1000000000000000000000000000')); $this->assertEquals('one nonillion', util::number_to_word('1000000000000000000000000000000')); $this->assertEquals('one decillion', util::number_to_word('1000000000000000000000000000000000')); $this->assertEquals('one', util::number_to_word('1000000000000000000000000000000000000000000')); }