/** * @depends testSlugging * @depends testOnBasePerc */ public function testOps($obp, $slg) { $baseball = new Baseball(); $ops = $baseball->calc_ops($obp, $slg); $expectedops = $obp + $slg; $this->assertEquals($expectedops, $ops); }
/** * @dataProvider providerCalcArgs * @covers Baseball::cal_avg * @return float * @param int $atbats * @param int $hits */ public function testCalc($atbats, $hits) { $baseball = new Baseball(); $result = $baseball->calc_avg($atbats, $hits); $expectedresult = $hits / $atbats; $formatexpectedresult = number_format($hits / $atbats, 3); $this->assertEquals($result, $formatexpectedresult); }
public function testCalcHitsAreStrings() { $atbats = 389; $hits = 'wefwf'; $baseball = new Baseball(); $result = $baseball->calc_avg($atbats, $hits); $formatexpectedresult = 0.0; $this->assertEquals($formatexpectedresult, $result); }
/** * @dataProvider providerCalcArgs * @covers Baseball::cal_avg * @return float * @param int $atbats * @param int $hits */ public function testCalc($atbats, $hits) { $baseball = new Baseball(); $result = $baseball->calc_avg($atbats, $hits); if (!is_numeric($atbats)) { $avg = 'Not a number'; return $avg; exit; } $expectedresult = $hits / $atbats; $formatexpectedresult = number_format($hits / $atbats, 3); $this->assertEquals($result, $formatexpectedresult); }