|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* MethodParserTest |
|
4
|
|
|
* |
|
5
|
|
|
* @author Piotr Olaszewski <[email protected]> |
|
6
|
|
|
*/ |
|
7
|
|
|
use WSDL\Parser\MethodParser; |
|
8
|
|
|
|
|
9
|
|
|
class MethodParserTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
10
|
|
|
{ |
|
11
|
|
|
private $_methodName; |
|
12
|
|
|
private $_methodDoc; |
|
13
|
|
|
|
|
14
|
|
|
protected function setUp() |
|
15
|
|
|
{ |
|
16
|
|
|
parent::setUp(); |
|
17
|
|
|
$this->_methodName = 'addUser'; |
|
18
|
|
|
$this->_methodDoc = <<<'DOC' |
|
19
|
|
|
/** |
|
20
|
|
|
* @desc Method to adding user |
|
21
|
|
|
* @param string $name |
|
22
|
|
|
* @param object $address @string=ip @string=mac |
|
23
|
|
|
* @param wrapper[] $relatives @className=\Mocks\MockClass |
|
24
|
|
|
* @return bool $return |
|
25
|
|
|
*/ |
|
26
|
|
|
DOC; |
|
27
|
|
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* @test |
|
31
|
|
|
*/ |
|
32
|
|
|
public function shouldParseMethodData() |
|
33
|
|
|
{ |
|
34
|
|
|
//when |
|
35
|
|
|
$parser = new MethodParser($this->_methodName, $this->_methodDoc); |
|
36
|
|
|
|
|
37
|
|
|
//then |
|
38
|
|
|
$this->assertEquals('Method to adding user', $parser->description()); |
|
39
|
|
|
$this->assertCount(3, $parser->parameters()); |
|
40
|
|
|
$this->assertInstanceOf('WSDL\Types\Simple', $parser->returning()); |
|
41
|
|
|
$this->assertEquals($this->_methodDoc, $parser->getDoc()); |
|
42
|
|
|
$this->assertEquals($this->_methodName, $parser->getName()); |
|
43
|
|
|
} |
|
44
|
|
|
|
|
45
|
|
|
/** |
|
46
|
|
|
* @test |
|
47
|
|
|
*/ |
|
48
|
|
|
public function shouldParseMethodAndReturnRawParameters() |
|
49
|
|
|
{ |
|
50
|
|
|
//when |
|
51
|
|
|
$parser = new MethodParser($this->_methodName, $this->_methodDoc); |
|
52
|
|
|
|
|
53
|
|
|
//then |
|
54
|
|
|
$this->assertEquals(array( |
|
55
|
|
|
'string $name', |
|
56
|
|
|
'object $address @string=ip @string=mac', |
|
57
|
|
|
'wrapper[] $relatives @className=\Mocks\MockClass' |
|
58
|
|
|
), $parser->getRawParameters()); |
|
59
|
|
|
} |
|
60
|
|
|
|
|
61
|
|
|
/** |
|
62
|
|
|
* @test |
|
63
|
|
|
*/ |
|
64
|
|
|
public function shouldParseMethodAndReturnRawReturn() |
|
65
|
|
|
{ |
|
66
|
|
|
//when |
|
67
|
|
|
$parser = new MethodParser($this->_methodName, $this->_methodDoc); |
|
68
|
|
|
|
|
69
|
|
|
//then |
|
70
|
|
|
$this->assertEquals('bool $return', $parser->getRawReturn()); |
|
71
|
|
|
} |
|
72
|
|
|
} |
|
73
|
|
|
|
You can fix this by adding a namespace to your class:
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.