summaryrefslogtreecommitdiff
path: root/tests/OsikaEvaluatorTest.php
blob: ce713a758ab555ac6812f53bb3aeddd0f57a9227 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<?php

class OsikaEvaluatorTest extends PHPUnit_Framework_TestCase {

  private $_evaluator;

  public function setUp() {
    require_once('../bin/lib/OsikaEvaluator.php');
    $this->_evaluator = new OsikaEvaluator();
  }

  public function handProvider() {
    $file = file('OsikaEvaluatorTest.tests');
    $ret = [];
    $switch = false;
    $item;
    foreach ($file as $line) {
      if (trim($line)) {
	if ($switch) {
	  $item[] = json_decode($line, TRUE);
	  $ret[] = $item;
	}
	else {
	  $item = [trim($line)];
	}
	$switch = !$switch;
      }
    }
    return $ret;
  }

  /**
   * @dataProvider handProvider
   **/
  public function testEvaluation($hand, $result) {
    $this->_evaluator->setHand($hand);
    $this->assertEquals($result, $this->_evaluator->evaluate());
  }

}

?>