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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
<?php
class OsikaParserTest extends PHPUnit_Framework_TestCase {
private $_parser;
public function setUp() {
require_once('../bin/lib/OsikaParser.php');
$this->_parser = new OsikaParser();
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 1
**/
public function testEmpty() {
$this->_parser->parse();
}
public function testLowerCase() {
$this->_parser->setHand('xxx|xxxx|xxx|xxx');
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
$this->_parser->setHand('XXX|XXXX|XXX|XXX');
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
$this->_parser->setHand('XXX|xxxx|XXX|XXX');
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
$this->_parser->setHand('XXX|XXXX|Xxx|XXX');
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
$this->_parser->setHand('XXx|XXXx|xXX|XxX');
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
}
public function testHonorSubstitution() {
$this->_parser = new OsikaParser();
$this->_parser->setHand('AKQJT|xxx|xxx|xx');
$this->assertEquals(['akqjt','xxx','xxx','xx'], $this->_parser->parse());
$this->_parser->setHand('AKDW10|xxx|xxx|xx');
$this->assertEquals(['akqjt','xxx','xxx','xx'], $this->_parser->parse());
$this->_parser->setHand('AKdJT|xxx|xxx|xx');
$this->assertEquals(['akqjt','xxx','xxx','xx'], $this->_parser->parse());
$this->_parser->setHand('AKQwT|xxx|xxx|xx');
$this->assertEquals(['akqjt','xxx','xxx','xx'], $this->_parser->parse());
}
public function testSpacesStrip() {
$this->_parser->setHand("\x09\x0A\x0C\x0D\x20xxx|xx\x09\x0A\x0C\x0D\x20xx|x\x09\x0A\x0C\x0D\x20xx|xxx\x09\x0A\x0C\x0D\x20\x09\x0A\x0C\x0D\x20");
$this->assertEquals(['xxx','xxxx','xxx','xxx'], $this->_parser->parse());
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 2
**/
public function testNotEnoughSuits() {
$this->_parser->setHand('xxxxxxx|xxxxxx|');
$this->_parser->parse();
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 2
**/
public function testTooManySuits() {
$this->_parser->setHand('xxx|xxxx|xxx|xxx|');
$this->_parser->parse();
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 3
**/
public function testInvalidCharacters() {
$this->_parser->setHand('a||a|akdjz98xxx0');
$this->_parser->parse();
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 4
**/
public function testDuplicateCard() {
$this->_parser->setHand('akdw|akdw|akd|t10');
$this->_parser->parse();
}
public function testCardSort() {
$this->_parser->setHand('akdj|akw|a|a9xxx');
$this->assertEquals(['akqj','akj','a','a9xxx'], $this->_parser->parse());
$this->_parser->setHand('kajd|twa|a|9axxx');
$this->assertEquals(['akqj','ajt','a','a9xxx'], $this->_parser->parse());
$this->_parser->setHand('akdj|akw|a|ax89x');
$this->assertEquals(['akqj','akj','a','a9x8x'], $this->_parser->parse());
}
/**
* @expectedException OsikaParserException
* @expectedExceptionCode 5
**/
public function testInvalidCardCount() {
$this->_parser->setHand('xxx|xxx|xxx|xxx');
$this->_parser->parse();
}
}
?>
|