| 1227 |
1227 |
} |
| 1228 |
1228 |
|
| 1229 |
1229 |
/** |
|
1230 |
+ * testParserStripsLeadingSlashFromNamespacedClassName |
|
1231 |
+ * |
|
1232 |
+ * @return void |
|
1233 |
+ * @covers PHP_Depend_Parser::_getNamespaceOrPackageName |
|
1234 |
+ * @group pdepend |
|
1235 |
+ * @group pdepend::parser |
|
1236 |
+ * @group unittest |
|
1237 |
+ */ |
|
1238 |
+ public function testParserStripsLeadingSlashFromNamespacedClassName() |
|
1239 |
+ { |
|
1240 |
+ $packages = self::parseSource('parser/' . __FUNCTION__ . '.php'); |
|
1241 |
+ $package = $packages->current(); |
|
1242 |
+ |
|
1243 |
+ $this->assertEquals('foo', $package->getName()); |
|
1244 |
+ } |
|
1245 |
+ |
|
1246 |
+ /** |
|
1247 |
+ * testParserStripsLeadingSlashFromNamespacedClassName |
|
1248 |
+ * |
|
1249 |
+ * @return void |
|
1250 |
+ * @covers PHP_Depend_Parser::_getNamespaceOrPackageName |
|
1251 |
+ * @group pdepend |
|
1252 |
+ * @group pdepend::parser |
|
1253 |
+ * @group unittest |
|
1254 |
+ */ |
|
1255 |
+ public function testParserStripsLeadingSlashFromNamespaceAliasedClassName() |
|
1256 |
+ { |
|
1257 |
+ $packages = self::parseSource('parser/' . __FUNCTION__ . '.php'); |
|
1258 |
+ $package = $packages->current() |
|
1259 |
+ ->getClasses() |
|
1260 |
+ ->current() |
|
1261 |
+ ->getParentClass() |
|
1262 |
+ ->getPackage(); |
|
1263 |
+ |
|
1264 |
+ $this->assertEquals('foo\bar\baz', $package->getName()); |
|
1265 |
+ } |
|
1266 |
+ |
|
1267 |
+ /** |
|
1268 |
+ * testParserStripsLeadingSlashFromInheritNamespacedClassName |
|
1269 |
+ * |
|
1270 |
+ * @return void |
|
1271 |
+ * @covers PHP_Depend_Parser::_parseQualifiedName |
|
1272 |
+ * @group pdepend |
|
1273 |
+ * @group pdepend::parser |
|
1274 |
+ * @group unittest |
|
1275 |
+ */ |
|
1276 |
+ public function testParserStripsLeadingSlashFromInheritNamespacedClassName() |
|
1277 |
+ { |
|
1278 |
+ $packages = self::parseSource('parser/' . __FUNCTION__ . '.php'); |
|
1279 |
+ $package = $packages->current() |
|
1280 |
+ ->getClasses() |
|
1281 |
+ ->current() |
|
1282 |
+ ->getParentClass() |
|
1283 |
+ ->getPackage(); |
|
1284 |
+ |
|
1285 |
+ $this->assertEquals('bar', $package->getName()); |
|
1286 |
+ } |
|
1287 |
+ |
|
1288 |
+ /** |
| 1230 |
1289 |
* Tests that the parser ignores variable class instantiation. |
| 1231 |
1290 |
* |
| 1232 |
1291 |
* http://bugs.xplib.de/index.php?do=details&task_id=10&project=3 |
|
2 |
+<?php |
|
3 |
+/** |
|
4 |
+ * This file is part of PHP_Depend. |
|
5 |
+ * |
|
6 |
+ * PHP Version 5 |
|
7 |
+ * |
|
8 |
+ * Copyright (c) 2008-2010, 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-2010 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 |
+require_once 'PHP/Depend.php'; |
|
53 |
+require_once 'PHP/Depend/Log/Summary/Xml.php'; |
|
54 |
+require_once 'PHP/Depend/Util/Type.php'; |
|
55 |
+ |
|
56 |
+/** |
|
57 |
+ * Test case for ticket #106, where internal classes appear in the metrics log |
|
58 |
+ * file. |
|
59 |
+ * |
|
60 |
+ * @category PHP |
|
61 |
+ * @package PHP_Depend |
|
62 |
+ * @subpackage Bugs |
|
63 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
64 |
+ * @copyright 2008-2010 Manuel Pichler. All rights reserved. |
|
65 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
66 |
+ * @version Release: @package_version@ |
|
67 |
+ * @link http://www.pdepend.org/ |
|
68 |
+ */ |
|
69 |
+class PHP_Depend_Bugs_DefaultNamespaceBug106Test extends PHP_Depend_Bugs_AbstractTest |
|
70 |
+{ |
|
71 |
+ /** |
|
72 |
+ * testAllocatedInternalClassWithLeadingBackslashNotAppearsInSummaryLogFile |
|
73 |
+ * |
|
74 |
+ * @return void |
|
75 |
+ * @covers stdClass |
|
76 |
+ * @group pdepend |
|
77 |
+ * @group pdepend::bugs |
|
78 |
+ * @group regressiontest |
|
79 |
+ */ |
|
80 |
+ public function testAllocatedInternalClassWithLeadingBackslashNotAppearsInSummaryLogFile() |
|
81 |
+ { |
|
82 |
+ $this->_runForTestCase(__METHOD__); |
|
83 |
+ } |
|
84 |
+ |
|
85 |
+ /** |
|
86 |
+ * testExtendedInternalClassWithLeadingBackslashNotAppearsInSummaryLogFile |
|
87 |
+ * |
|
88 |
+ * @return void |
|
89 |
+ * @covers stdClass |
|
90 |
+ * @group pdepend |
|
91 |
+ * @group pdepend::bugs |
|
92 |
+ * @group regressiontest |
|
93 |
+ */ |
|
94 |
+ public function testExtendedInternalClassWithLeadingBackslashNotAppearsInSummaryLogFile() |
|
95 |
+ { |
|
96 |
+ $this->_runForTestCase(__METHOD__); |
|
97 |
+ } |
|
98 |
+ |
|
99 |
+ /** |
|
100 |
+ * Runs PHP_Depend with the summary logger, against a source file associated |
|
101 |
+ * with the given test case. |
|
102 |
+ * |
|
103 |
+ * @param string $testCase Name of the calling test case. |
|
104 |
+ * |
|
105 |
+ * @return void |
|
106 |
+ */ |
|
107 |
+ private function _runForTestCase($testCase) |
|
108 |
+ { |
|
109 |
+ $uri = $this->createRunResourceURI(__FUNCTION__); |
|
110 |
+ |
|
111 |
+ $logger = new PHP_Depend_Log_Summary_Xml(); |
|
112 |
+ $logger->setLogFile($uri); |
|
113 |
+ |
|
114 |
+ $pdepend = new PHP_Depend(); |
|
115 |
+ $pdepend->addFile(self::getSourceFileForTestCase($testCase)); |
|
116 |
+ $pdepend->addLogger($logger); |
|
117 |
+ $pdepend->analyze(); |
|
118 |
+ |
|
119 |
+ $dom = new DOMDocument('1.0', 'UTF-8'); |
|
120 |
+ $dom->load($uri); |
|
121 |
+ |
|
122 |
+ $xpath = new DOMXPath($dom); |
|
123 |
+ $result = $xpath->query('//class[@name="RuntimeException"]'); |
|
124 |
+ |
|
125 |
+ $this->assertEquals(0, $result->length); |
|
126 |
+ } |
|
127 |
+} |
|
2 |
+<?php |
|
3 |
+/** |
|
4 |
+ * This file is part of PHP_Depend. |
|
5 |
+ * |
|
6 |
+ * PHP Version 5 |
|
7 |
+ * |
|
8 |
+ * Copyright (c) 2008-2010, 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 QualityAssurance |
|
41 |
+ * @package PHP_Depend |
|
42 |
+ * @subpackage Util |
|
43 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
44 |
+ * @copyright 2008-2010 Manuel Pichler. All rights reserved. |
|
45 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
46 |
+ * @version SVN: $Id$ |
|
47 |
+ * @link http://pdepend.org/ |
|
48 |
+ */ |
|
49 |
+ |
|
50 |
+require_once dirname(__FILE__) . '/../AbstractTest.php'; |
|
51 |
+ |
|
52 |
+require_once 'PHP/Depend/Util/Type.php'; |
|
53 |
+ |
|
54 |
+/** |
|
55 |
+ * Test case for type utility class. |
|
56 |
+ * |
|
57 |
+ * @category QualityAssurance |
|
58 |
+ * @package PHP_Depend |
|
59 |
+ * @subpackage Util |
|
60 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
61 |
+ * @copyright 2008-2010 Manuel Pichler. All rights reserved. |
|
62 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
63 |
+ * @version Release: @package_version@ |
|
64 |
+ * @link http://pdepend.org/ |
|
65 |
+ */ |
|
66 |
+class PHP_Depend_Util_TypeTest extends PHP_Depend_AbstractTest |
|
67 |
+{ |
|
68 |
+ /** |
|
69 |
+ * testIsInternalTypeDetectsInternalClassPrefixedWithBackslash |
|
70 |
+ * |
|
71 |
+ * @return void |
|
72 |
+ * @covers PHP_Depend_Util_Type::isInternalType |
|
73 |
+ * @group pdepend |
|
74 |
+ * @group pdepend::util |
|
75 |
+ * @group unittest |
|
76 |
+ */ |
|
77 |
+ public function testIsInternalTypeDetectsInternalClassPrefixedWithBackslash() |
|
78 |
+ { |
|
79 |
+ $isInternal = PHP_Depend_Util_Type::isInternalType('\LogicException'); |
|
80 |
+ $this->assertTrue($isInternal); |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ /** |
|
84 |
+ * testGetTypePackageReturnsExpectedExtensionNameForClassPrefixedWithBackslash |
|
85 |
+ * |
|
86 |
+ * @return void |
|
87 |
+ * @covers PHP_Depend_Util_Type::getTypePackage |
|
88 |
+ * @group pdepend |
|
89 |
+ * @group pdepend::util |
|
90 |
+ * @group unittest |
|
91 |
+ */ |
|
92 |
+ public function testGetTypePackageReturnsExpectedExtensionNameForClassPrefixedWithBackslash() |
|
93 |
+ { |
|
94 |
+ $extensionName = PHP_Depend_Util_Type::getTypePackage('\LogicException'); |
|
95 |
+ $this->assertEquals('+spl', $extensionName); |
|
96 |
+ } |
|
97 |
+} |