예제 #1
0
 /**
  * @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);
 }
예제 #2
0
 /**
  * @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);
 }
예제 #3
0
 public function testCalcHitsAreStrings()
 {
     $atbats = 389;
     $hits = 'wefwf';
     $baseball = new Baseball();
     $result = $baseball->calc_avg($atbats, $hits);
     $formatexpectedresult = 0.0;
     $this->assertEquals($formatexpectedresult, $result);
 }
예제 #4
0
 /**
  * @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);
 }