|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace AlgoWeb\xsdTypes; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Generated Test Class. |
|
8
|
|
|
*/ |
|
9
|
|
View Code Duplication |
class xsNMTOKENTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @dataProvider testxsNMTOKENValidDataProvider |
|
13
|
|
|
* @param mixed $input |
|
14
|
|
|
* @param mixed $message |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testxsNMTOKENValid($input, $message) |
|
17
|
|
|
{ |
|
18
|
|
|
try { |
|
19
|
|
|
$d = new xsNMTOKEN($input); |
|
20
|
|
|
$s = (string)$d; |
|
|
|
|
|
|
21
|
|
|
} catch (\Exception $e) { |
|
22
|
|
|
$this->fail($message . ' with Exception ' . $e->getMessage()); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testxsNMTOKENValidDataProvider() |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
array('ABCD', ''), |
|
30
|
|
|
array('123_456', ''), |
|
31
|
|
|
array(' starts_with_a_space', 'when parsed, leading spaces will be removed'), |
|
32
|
|
|
); |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* @dataProvider testxsNMTOKENInvalidDataProvider |
|
37
|
|
|
* @param mixed $input |
|
38
|
|
|
* @param mixed $message |
|
39
|
|
|
*/ |
|
40
|
|
|
public function testxsNMTOKENInvalid($input, $message) |
|
41
|
|
|
{ |
|
42
|
|
|
try { |
|
43
|
|
|
$d = new xsNMTOKEN($input); |
|
44
|
|
|
$s = (string)$d; |
|
45
|
|
|
$this->fail($message); |
|
46
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
47
|
|
|
} |
|
48
|
|
|
$this->assertEquals('', $s, $message); |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
public function testxsNMTOKENInvalidDataProvider() |
|
52
|
|
|
{ |
|
53
|
|
|
return array( |
|
54
|
|
|
array('contains a space', 'value must not contain a space'), |
|
55
|
|
|
array('', 'an empty value is not valid, unless xsi:nil is used'), |
|
56
|
|
|
); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
/** |
|
60
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
61
|
|
|
* This method is called before a test is executed. |
|
62
|
|
|
*/ |
|
63
|
|
|
protected function setUp() |
|
64
|
|
|
{ |
|
65
|
|
|
parent::setUp(); |
|
66
|
|
|
} |
|
67
|
|
|
|
|
68
|
|
|
/** |
|
69
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
70
|
|
|
* This method is called after a test is executed. |
|
71
|
|
|
*/ |
|
72
|
|
|
protected function tearDown() |
|
73
|
|
|
{ |
|
74
|
|
|
parent::tearDown(); |
|
75
|
|
|
} |
|
76
|
|
|
} |
|
77
|
|
|
|
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.