|
2 |
+<?php |
|
3 |
+/** |
|
4 |
+ * This file is part of PHP_Depend. |
|
5 |
+ * |
|
6 |
+ * PHP Version 5 |
|
7 |
+ * |
|
8 |
+ * Copyright (c) 2008-2009, Manuel Pichler <mapi@pdepend.org>. |
|
9 |
+ * All rights reserved. |
|
10 |
+ * |
|
11 |
+ * Redistribution and use in source and binary forms, with or without |
|
12 |
+ * modification, are permitted provided that the following conditions |
|
13 |
+ * are met: |
|
14 |
+ * |
|
15 |
+ * * Redistributions of source code must retain the above copyright |
|
16 |
+ * notice, this list of conditions and the following disclaimer. |
|
17 |
+ * |
|
18 |
+ * * Redistributions in binary form must reproduce the above copyright |
|
19 |
+ * notice, this list of conditions and the following disclaimer in |
|
20 |
+ * the documentation and/or other materials provided with the |
|
21 |
+ * distribution. |
|
22 |
+ * |
|
23 |
+ * * Neither the name of Manuel Pichler nor the names of his |
|
24 |
+ * contributors may be used to endorse or promote products derived |
|
25 |
+ * from this software without specific prior written permission. |
|
26 |
+ * |
|
27 |
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
|
28 |
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
|
29 |
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
|
30 |
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
|
31 |
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
|
32 |
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
33 |
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
|
34 |
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
|
35 |
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
|
36 |
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN |
|
37 |
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
|
38 |
+ * POSSIBILITY OF SUCH DAMAGE. |
|
39 |
+ * |
|
40 |
+ * @category PHP |
|
41 |
+ * @package PHP_Depend |
|
42 |
+ * @subpackage Bugs |
|
43 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
44 |
+ * @copyright 2008-2009 Manuel Pichler. All rights reserved. |
|
45 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
46 |
+ * @version SVN: $Id$ |
|
47 |
+ * @link http://www.pdepend.org/ |
|
48 |
+ */ |
|
49 |
+ |
|
50 |
+require_once dirname(__FILE__) . '/AbstractTest.php'; |
|
51 |
+ |
|
52 |
+/** |
|
53 |
+ * Test case for bug 102. The current parser implementation does not handle |
|
54 |
+ * the <b>namespace</b> keyword in parameter type hints. |
|
55 |
+ * |
|
56 |
+ * http://tracker.pdepend.org/pdepend/issue_tracker/issue/102 |
|
57 |
+ * |
|
58 |
+ * @category PHP |
|
59 |
+ * @package PHP_Depend |
|
60 |
+ * @subpackage Bugs |
|
61 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
62 |
+ * @copyright 2008-2009 Manuel Pichler. All rights reserved. |
|
63 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
64 |
+ * @version Release: @package_version@ |
|
65 |
+ * @link http://www.pdepend.org/ |
|
66 |
+ */ |
|
67 |
+class PHP_Depend_Bugs_NamespaceKeywordInParameterTypeHintBug102Test |
|
68 |
+ extends PHP_Depend_Bugs_AbstractTest |
|
69 |
+{ |
|
70 |
+ /** |
|
71 |
+ * testParserHandlesNamespaceKeywordInFunctionParameterTypeHint |
|
72 |
+ * |
|
73 |
+ * @return void |
|
74 |
+ * @covers PHP_Depend_Parser |
|
75 |
+ * @group parser |
|
76 |
+ * @group bugs |
|
77 |
+ */ |
|
78 |
+ public function testParserHandlesNamespaceKeywordInFunctionParameterTypeHint() |
|
79 |
+ { |
|
80 |
+ $packages = self::parseTestCaseSource(__METHOD__); |
|
81 |
+ $parameter = $packages->current() |
|
82 |
+ ->getFunctions() |
|
83 |
+ ->current() |
|
84 |
+ ->getParameters() |
|
85 |
+ ->current(); |
|
86 |
+ |
|
87 |
+ $this->assertEquals('foo\bar', $parameter->getClass()->getPackage()->getName()); |
|
88 |
+ } |
|
89 |
+ |
|
90 |
+ /** |
|
91 |
+ * testParserHandlesNamespaceKeywordInMethodParameterTypeHint |
|
92 |
+ * |
|
93 |
+ * @return void |
|
94 |
+ * @covers PHP_Depend_Parser |
|
95 |
+ * @group parser |
|
96 |
+ * @group bugs |
|
97 |
+ */ |
|
98 |
+ public function testParserHandlesNamespaceKeywordInMethodParameterTypeHint() |
|
99 |
+ { |
|
100 |
+ $packages = self::parseTestCaseSource(__METHOD__); |
|
101 |
+ $parameter = $packages->current() |
|
102 |
+ ->getClasses() |
|
103 |
+ ->current() |
|
104 |
+ ->getMethods() |
|
105 |
+ ->current() |
|
106 |
+ ->getParameters() |
|
107 |
+ ->current(); |
|
108 |
+ |
|
109 |
+ $this->assertEquals('foo\bar', $parameter->getClass()->getPackage()->getName()); |
|
110 |
+ } |
|
111 |
+} |