summaryrefslogtreecommitdiff
path: root/tests/OsikaEvaluatorTest.php
blob: 8df81a0dc218d538561df9a920a1245fe4ecb434 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php

/**
 * DISCLAIMER!
 *
 * Do NOT. Under ANY circumstances. Use this test set as an evaluation
 * for OSiKa algorithm correctness.
 *
 * It's SOLE purpose was to ensure correct transition from the previous
 * codebase and it ONLY checks if all the calculation and output collection
 * was handled the same way as with the previous script.
 *
 * This test set does NOT ensure that the trick values coming out of the algorithm
 * are in any way correct, in terms of bridge theory.
 **/

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());
  }

}

?>