function testCaluclateTotalSteps() { $sc = new SupportContract(); $sc->set(array('domain_name' => 'Test', 'start_date' => '2010-01-01', 'end_date' => '2010-04-30', 'hourly_rate' => '120', 'support_hours' => '.5', 'monthly_rate' => '50')); $sc->save(); $h = new Hour(); $h->set(array('description' => 'Test', 'support_contract_id' => $sc->id, 'date' => '2010-02-20', 'hours' => '2.5')); $h->save(); $date_range = array('end_date' => '2010-03-31'); #make sure we are getting the active months $months = $sc->activeMonths($date_range); $this->assertEqual(count($months), 3); $this->assertEqual(array_pop($months), '201003'); #make sure we are calculating monthly base rate $this->assertEqual($sc->calculateMonthlyBaseRate(201002), 50); #make sure we are getting the hourly rate $this->assertEqual($sc->getHourlyRate(), 120); $this->assertEqual($sc->get('hourly_rate'), 120); #make sure we are calculating the monthly charge: base rate + logged hours - included support hours $monthly_charge = $sc->calculateMonthlyCharge($h->getHours(), '201002'); $this->assertEqual($monthly_charge, '290'); ## clean up $sc->destroyAssociatedRecords(); $sc->delete(); }