|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace AlgoWeb\xsdTypes; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Generated Test Class. |
|
8
|
|
|
*/ |
|
9
|
|
View Code Duplication |
class xsNegativeIntegerTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @dataProvider testxsNegativeIntegerValidDataProvider |
|
13
|
|
|
* @param mixed $input |
|
14
|
|
|
* @param mixed $message |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testxsNegativeIntegerValid($input, $message) |
|
17
|
|
|
{ |
|
18
|
|
|
try { |
|
19
|
|
|
$d = new xsNegativeInteger($input); |
|
20
|
|
|
$s = (string)$d; |
|
|
|
|
|
|
21
|
|
|
} catch (\Exception $e) { |
|
22
|
|
|
$this->fail($message . ' with Exception ' . $e->getMessage()); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testxsNegativeIntegerValidDataProvider() |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
array('-3', ''), |
|
30
|
|
|
array('-00122', 'leading zeros are permitted'), |
|
31
|
|
|
); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* @dataProvider testxsNegativeIntegerInvalidDataProvider |
|
36
|
|
|
* @param mixed $input |
|
37
|
|
|
* @param mixed $message |
|
38
|
|
|
*/ |
|
39
|
|
|
public function testxsNegativeIntegerInvalid($input, $message) |
|
40
|
|
|
{ |
|
41
|
|
|
try { |
|
42
|
|
|
$d = new xsNegativeInteger($input); |
|
43
|
|
|
$s = (string)$d; |
|
44
|
|
|
$this->fail($message); |
|
45
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
$this->assertEquals('', $s, $message); |
|
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
|
50
|
|
|
public function testxsNegativeIntegerInvalidDataProvider() |
|
51
|
|
|
{ |
|
52
|
|
|
return array( |
|
53
|
|
|
array('0', '0 is not considered negative'), |
|
54
|
|
|
array('122', 'value cannot be positive'), |
|
55
|
|
|
array('+3', 'value cannot be positive'), |
|
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.