You are here

public function BirthdaysBirthdayTestCase::testAgeCalculation in Birthdays 7

Tests age calculation.

File

./birthdays.test, line 39
Unit tests for the Birthdays module.

Class

BirthdaysBirthdayTestCase
Unit tests for the BirthdaysBirthday class.

Code

public function testAgeCalculation() {

  // Assume it's 02/24/2012.
  $now = mktime(3, 54, 23, 2, 24, 2012);
  $this
    ->assertEqual(date('m/d/Y', $now), '02/24/2012');

  // Test age calculation.
  $this
    ->assertEqual(BirthdaysBirthday::fromArray(array(
    'month' => 2,
    'day' => 25,
    'year' => 1985,
  ))
    ->getCurrentAge($now), 26);
  $this
    ->assertEqual(BirthdaysBirthday::fromArray(array(
    'month' => 2,
    'day' => 16,
    'year' => 1985,
  ))
    ->getCurrentAge($now), 27);
  $this
    ->assertEqual(BirthdaysBirthday::fromArray(array(
    'month' => 7,
    'day' => 3,
    'year' => 1993,
  ))
    ->getCurrentAge($now), 18);
}