|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace AlgoWeb\xsdTypes; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Generated Test Class. |
|
8
|
|
|
*/ |
|
9
|
|
View Code Duplication |
class xsIntTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @dataProvider testxsIntValidDataProvider |
|
13
|
|
|
* @param mixed $input |
|
14
|
|
|
* @param mixed $message |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testxsIntValid($input, $message) |
|
17
|
|
|
{ |
|
18
|
|
|
try { |
|
19
|
|
|
$d = new xsInt($input); |
|
20
|
|
|
$s = (string)$d; |
|
|
|
|
|
|
21
|
|
|
} catch (\Exception $e) { |
|
22
|
|
|
$this->fail($message . ' with Exception ' . $e->getMessage()); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testxsIntValidDataProvider() |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
array('+3', ''), |
|
30
|
|
|
array('122', ''), |
|
31
|
|
|
array('0', ''), |
|
32
|
|
|
array('-12312', ''), |
|
33
|
|
|
); |
|
34
|
|
|
} |
|
35
|
|
|
|
|
36
|
|
|
/** |
|
37
|
|
|
* @dataProvider testxsIntInvalidDataProvider |
|
38
|
|
|
* @param mixed $input |
|
39
|
|
|
* @param mixed $message |
|
40
|
|
|
*/ |
|
41
|
|
|
public function testxsIntInvalid($input, $message) |
|
42
|
|
|
{ |
|
43
|
|
|
try { |
|
44
|
|
|
$d = new xsInt($input); |
|
45
|
|
|
$s = (string)$d; |
|
46
|
|
|
$this->fail($message); |
|
47
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
$this->assertEquals('', $s, $message); |
|
|
|
|
|
|
50
|
|
|
} |
|
51
|
|
|
|
|
52
|
|
|
public function testxsIntInvalidDataProvider() |
|
53
|
|
|
{ |
|
54
|
|
|
return array( |
|
55
|
|
|
array('2147483650', 'number is too large'), |
|
56
|
|
|
array('3.0', 'value must not contain a decimal point'), |
|
57
|
|
|
array('', 'an empty value is not valid, unless xsi:nil is used'), |
|
58
|
|
|
); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
63
|
|
|
* This method is called before a test is executed. |
|
64
|
|
|
*/ |
|
65
|
|
|
protected function setUp() |
|
66
|
|
|
{ |
|
67
|
|
|
parent::setUp(); |
|
68
|
|
|
} |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
72
|
|
|
* This method is called after a test is executed. |
|
73
|
|
|
*/ |
|
74
|
|
|
protected function tearDown() |
|
75
|
|
|
{ |
|
76
|
|
|
parent::tearDown(); |
|
77
|
|
|
} |
|
78
|
|
|
} |
|
79
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.