|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
|
|
4
|
|
|
namespace AlgoWeb\xsdTypes; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Generated Test Class. |
|
8
|
|
|
*/ |
|
9
|
|
View Code Duplication |
class xsNameTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
/** |
|
12
|
|
|
* @dataProvider testxsNameValidDataProvider |
|
13
|
|
|
* @param mixed $input |
|
14
|
|
|
* @param mixed $message |
|
15
|
|
|
*/ |
|
16
|
|
|
public function testxsNameValid($input, $message) |
|
17
|
|
|
{ |
|
18
|
|
|
try { |
|
19
|
|
|
$d = new xsName($input); |
|
20
|
|
|
$s = (string)$d; |
|
|
|
|
|
|
21
|
|
|
} catch (\Exception $e) { |
|
22
|
|
|
$this->fail($message . ' with Exception ' . $e->getMessage()); |
|
23
|
|
|
} |
|
24
|
|
|
} |
|
25
|
|
|
|
|
26
|
|
|
public function testxsNameValidDataProvider() |
|
27
|
|
|
{ |
|
28
|
|
|
return array( |
|
29
|
|
|
array('myElement', ''), |
|
30
|
|
|
array('_my.Element', ''), |
|
31
|
|
|
array('my-element', ''), |
|
32
|
|
|
array('pre:myelement3', 'this is recommended only if pre is a namespace prefix; otherwise, colons ' . |
|
33
|
|
|
'should not be used'), |
|
34
|
|
|
); |
|
35
|
|
|
} |
|
36
|
|
|
|
|
37
|
|
|
/** |
|
38
|
|
|
* @dataProvider testxsNameInvalidDataProvider |
|
39
|
|
|
* @param mixed $input |
|
40
|
|
|
* @param mixed $message |
|
41
|
|
|
*/ |
|
42
|
|
|
public function testxsNameInvalid($input, $message) |
|
43
|
|
|
{ |
|
44
|
|
|
try { |
|
45
|
|
|
$d = new xsName($input); |
|
46
|
|
|
$s = (string)$d; |
|
47
|
|
|
$this->fail($message); |
|
48
|
|
|
} catch (\Exception $e) { |
|
|
|
|
|
|
49
|
|
|
} |
|
50
|
|
|
$this->assertEquals('', $s, $message); |
|
|
|
|
|
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
public function testxsNameInvalidDataProvider() |
|
54
|
|
|
{ |
|
55
|
|
|
return array( |
|
56
|
|
|
array('-myelement', 'a Name must not start with a hyphen'), |
|
57
|
|
|
array('3rdElement', 'a Name must not start with a number'), |
|
58
|
|
|
array('', 'an empty value is not valid, unless xsi:nil is used'), |
|
59
|
|
|
); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
64
|
|
|
* This method is called before a test is executed. |
|
65
|
|
|
*/ |
|
66
|
|
|
protected function setUp() |
|
67
|
|
|
{ |
|
68
|
|
|
parent::setUp(); |
|
69
|
|
|
} |
|
70
|
|
|
|
|
71
|
|
|
/** |
|
72
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
73
|
|
|
* This method is called after a test is executed. |
|
74
|
|
|
*/ |
|
75
|
|
|
protected function tearDown() |
|
76
|
|
|
{ |
|
77
|
|
|
parent::tearDown(); |
|
78
|
|
|
} |
|
79
|
|
|
} |
|
80
|
|
|
|
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.