Arbit - project tracking

PHPMD

Browse source code

File: / test/ PHP/ PMD/ Node/ ClassTest.php

Type
text/plain text/plain
Last Author
mapi
Version
200
Line Rev. Author Source
1 39 mapi <?php
2 mapi /**
3 mapi * This file is part of PHP_PMD.
4 mapi *
5 mapi * PHP Version 5
6 mapi *
7 174 mapi * Copyright (c) 2009-2010, Manuel Pichler <mapi@phpmd.org>.
8 39 mapi * All rights reserved.
9 mapi *
10 mapi * Redistribution and use in source and binary forms, with or without
11 mapi * modification, are permitted provided that the following conditions
12 mapi * are met:
13 mapi *
14 mapi * * Redistributions of source code must retain the above copyright
15 mapi * notice, this list of conditions and the following disclaimer.
16 mapi *
17 mapi * * Redistributions in binary form must reproduce the above copyright
18 mapi * notice, this list of conditions and the following disclaimer in
19 mapi * the documentation and/or other materials provided with the
20 mapi * distribution.
21 mapi *
22 mapi * * Neither the name of Manuel Pichler nor the names of his
23 mapi * contributors may be used to endorse or promote products derived
24 mapi * from this software without specific prior written permission.
25 mapi *
26 mapi * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 mapi * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 mapi * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
29 mapi * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
30 mapi * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
31 mapi * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
32 mapi * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
33 mapi * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
34 mapi * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
35 mapi * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
36 mapi * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
37 mapi * POSSIBILITY OF SUCH DAMAGE.
38 mapi *
39 54 mapi * @category PHP
40 mapi * @package PHP_PMD
41 84 mapi * @subpackage Node
42 174 mapi * @author Manuel Pichler <mapi@phpmd.org>
43 150 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
44 54 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
45 mapi * @version SVN: $Id$
46 174 mapi * @link http://phpmd.org
47 39 mapi */
48 mapi
49 99 mapi require_once dirname(__FILE__) . '/../AbstractTest.php';
50 39 mapi
51 200 mapi require_once 'PHP/PMD/AbstractRule.php';
52 mapi require_once 'PHP/PMD/Node/Class.php';
53 99 mapi require_once 'PHP/Depend/Code/Class.php';
54 mapi require_once 'PHP/Depend/Code/Method.php';
55 39 mapi
56 mapi /**
57 99 mapi * Test case for the class node implementation.
58 39 mapi *
59 54 mapi * @category PHP
60 mapi * @package PHP_PMD
61 84 mapi * @subpackage Node
62 174 mapi * @author Manuel Pichler <mapi@phpmd.org>
63 150 mapi * @copyright 2009-2010 Manuel Pichler. All rights reserved.
64 54 mapi * @license http://www.opensource.org/licenses/bsd-license.php BSD License
65 mapi * @version Release: @package_version@
66 174 mapi * @link http://phpmd.org
67 39 mapi */
68 200 mapi class PHP_PMD_Node_ClassTest extends PHP_PMD_AbstractTest
69 39 mapi {
70 mapi /**
71 99 mapi * testGetMethodNamesReturnsExpectedResult
72 39 mapi *
73 99 mapi * @return void
74 200 mapi * @covers PHP_PMD_Node_Class
75 mapi * @covers PHP_PMD_Node_AbstractType
76 99 mapi * @group phpmd
77 mapi * @group phpmd::node
78 mapi * @group unittest
79 39 mapi */
80 99 mapi public function testGetMethodNamesReturnsExpectedResult()
81 39 mapi {
82 99 mapi $class = new PHP_Depend_Code_Class(null);
83 mapi $class->addMethod(new PHP_Depend_Code_Method(__CLASS__));
84 mapi $class->addMethod(new PHP_Depend_Code_Method(__FUNCTION__));
85 39 mapi
86 200 mapi $node = new PHP_PMD_Node_Class($class);
87 99 mapi $this->assertEquals(array(__CLASS__, __FUNCTION__), $node->getMethodNames());
88 39 mapi }
89 200 mapi
90 mapi /**
91 mapi * testHasSuppressWarningsAnnotationForReturnsTrue
92 mapi *
93 mapi * @return void
94 mapi * @covers PHP_PMD_Node_AbstractNode
95 mapi * @group phpmd
96 mapi * @group phpmd::node
97 mapi * @group unittest
98 mapi */
99 mapi public function testHasSuppressWarningsAnnotationForReturnsTrue()
100 mapi {
101 mapi $class = new PHP_Depend_Code_Class(null);
102 mapi $class->setDocComment('/** @SuppressWarnings("PMD") */');
103 mapi
104 mapi $rule = $this->getMock('PHP_PMD_AbstractRule');
105 mapi
106 mapi $node = new PHP_PMD_Node_Class($class);
107 mapi
108 mapi $this->assertTrue($node->hasSuppressWarningsAnnotationFor($rule));
109 mapi }
110 99 mapi }