|
2 |
+<?php |
|
3 |
+/** |
|
4 |
+ * This file is part of the static reflection component. |
|
5 |
+ * |
|
6 |
+ * PHP Version 5 |
|
7 |
+ * |
|
8 |
+ * Copyright (c) 2009-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 pdepend\reflection\regression |
|
42 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
43 |
+ * @copyright 2009-2010 Manuel Pichler. All rights reserved. |
|
44 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
45 |
+ * @version SVN: $Id$ |
|
46 |
+ * @link http://pdepend.org/ |
|
47 |
+ */ |
|
48 |
+ |
|
49 |
+namespace pdepend\reflection\regression; |
|
50 |
+ |
|
51 |
+require_once 'PHPUnit/Framework.php'; |
|
52 |
+ |
|
53 |
+require_once 'Bug005Test.php'; |
|
54 |
+ |
|
55 |
+/** |
|
56 |
+ * Main test suite. |
|
57 |
+ * |
|
58 |
+ * @category PHP |
|
59 |
+ * @package pdepend\reflection\regression |
|
60 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
61 |
+ * @copyright 2009-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 AllTests extends \PHPUnit_Framework_TestSuite |
|
67 |
+{ |
|
68 |
+ /** |
|
69 |
+ * Constructs a new test suite instance. |
|
70 |
+ */ |
|
71 |
+ public function __construct() |
|
72 |
+ { |
|
73 |
+ $this->setName( 'org::pdepend::reflection::regression::AllTests' ); |
|
74 |
+ |
|
75 |
+ \PHPUnit_Util_Filter::addDirectoryToWhitelist( |
|
76 |
+ realpath( dirname( __FILE__ ) . '/../../source/' ) |
|
77 |
+ ); |
|
78 |
+ |
|
79 |
+ $this->addTestSuite( '\pdepend\reflection\regression\Bug005Test' ); |
|
80 |
+ } |
|
81 |
+ |
|
82 |
+ /** |
|
83 |
+ * Returns a test suite instance. |
|
84 |
+ * |
|
85 |
+ * @return PHPUnit_Framework_TestSuite |
|
86 |
+ */ |
|
87 |
+ public static function suite() |
|
88 |
+ { |
|
89 |
+ return new AllTests(); |
|
90 |
+ } |
|
91 |
+} |
|
2 |
+<?php |
|
3 |
+/** |
|
4 |
+ * This file is part of the static reflection component. |
|
5 |
+ * |
|
6 |
+ * PHP Version 5 |
|
7 |
+ * |
|
8 |
+ * Copyright (c) 2009-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 pdepend\reflection\regression |
|
42 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
43 |
+ * @copyright 2009-2010 Manuel Pichler. All rights reserved. |
|
44 |
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD License |
|
45 |
+ * @version SVN: $Id$ |
|
46 |
+ * @link http://pdepend.org/ |
|
47 |
+ */ |
|
48 |
+ |
|
49 |
+namespace pdepend\reflection\regression; |
|
50 |
+ |
|
51 |
+use pdepend\reflection\queries\ReflectionFileQuery; |
|
52 |
+use pdepend\reflection\queries\ReflectionDirectoryQuery; |
|
53 |
+ |
|
54 |
+require_once 'BaseTest.php'; |
|
55 |
+ |
|
56 |
+/** |
|
57 |
+ * Test case for ticket #5 |
|
58 |
+ * |
|
59 |
+ * http://tracker.pdepend.org/static_reflection/issue_tracker/issue/5 |
|
60 |
+ * |
|
61 |
+ * @category PHP |
|
62 |
+ * @package pdepend\reflection\regression |
|
63 |
+ * @author Manuel Pichler <mapi@pdepend.org> |
|
64 |
+ * @copyright 2009-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://pdepend.org/ |
|
68 |
+ */ |
|
69 |
+class Bug005Test extends \pdepend\reflection\BaseTest |
|
70 |
+{ |
|
71 |
+ /** |
|
72 |
+ * testFileQueryNormalizesRelativePath |
|
73 |
+ * |
|
74 |
+ * @return void |
|
75 |
+ * @covers \stdClass |
|
76 |
+ * @group reflection |
|
77 |
+ * @group reflection::regression |
|
78 |
+ * @group regressiontest |
|
79 |
+ */ |
|
80 |
+ public function testFileQueryNormalizesRelativePath() |
|
81 |
+ { |
|
82 |
+ $path = $this->getPathnameForClass( '\pdepend\reflection\regression\Bug005' ); |
|
83 |
+ |
|
84 |
+ $absolute = realpath( $path ); |
|
85 |
+ $relative = dirname( $path ) . '/../regression/' . basename( $path ); |
|
86 |
+ |
|
87 |
+ $query = new ReflectionFileQuery( $this->createContext() ); |
|
88 |
+ $result = $query->find( $relative ); |
|
89 |
+ |
|
90 |
+ $this->assertEquals( $absolute, $result[0]->getFilename() ); |
|
91 |
+ } |
|
92 |
+ |
|
93 |
+ /** |
|
94 |
+ * testDirectoryQueryNormalizesRelativePath |
|
95 |
+ * |
|
96 |
+ * @return void |
|
97 |
+ * @covers \stdClass |
|
98 |
+ * @group reflection |
|
99 |
+ * @group reflection::regression |
|
100 |
+ * @group regressiontest |
|
101 |
+ */ |
|
102 |
+ public function testDirectoryQueryNormalizesRelativePath() |
|
103 |
+ { |
|
104 |
+ $path = $this->getPathnameForClass( '\pdepend\reflection\regression\Bug005' ); |
|
105 |
+ |
|
106 |
+ $absolute = realpath( $path ); |
|
107 |
+ $relative = dirname( $path ) . '/../regression/'; |
|
108 |
+ |
|
109 |
+ $query = new ReflectionDirectoryQuery( $this->createContext() ); |
|
110 |
+ $result = $query->find( $relative ); |
|
111 |
+ |
|
112 |
+ $this->assertEquals( $absolute, $result[0]->getFilename() ); |
|
113 |
+ } |
|
114 |
+} |