. */ declare(strict_types=1); namespace Fisharebest\Webtrees; /** * Test the Age functions */ class AgeTest extends TestCase { /** * Test that the class exists * * @return void */ public function testClassExists(): void { $this->assertTrue(class_exists('\Fisharebest\Webtrees\Age')); } /** * @dataProvider ageProvider * @covers \Fisharebest\Webtrees\Age::__construct * @covers \Fisharebest\Webtrees\Age::asText * @covers \Fisharebest\Webtrees\Age::extractNumber * @return void */ public function testConstructor($ageTest, $ageAsText): void { $age = new Age($ageTest); $this->assertSame($ageAsText, $age->asText()); } public function ageProvider() { return [ ['stillborn','(stillborn)'], ['infant','(in infancy)'], ['child','(in childhood)'], ['6y 3m','(aged 6 years, 3 months)'], ['> 6y 3m 2d','(aged more than 6 years, 3 months, 2 days)'], ['< 6y 3m 2d','(aged less than 6 years, 3 months, 2 days)'], ['3w','(aged 3 weeks)'], ['6y','(aged 6)'] ]; } }