Subversion Repositories Applications.framework

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5 aurelien 1
<?php
2
/**
3
 * Tests for the PHP_CodeSniffer:isCamelCaps method.
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PHP_CodeSniffer
9
 * @author    Greg Sherwood <gsherwood@squiz.net>
10
 * @author    Marc McIntyre <mmcintyre@squiz.net>
11
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
12
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
13
 * @version   CVS: $Id: IsCamelCapsTest.php,v 1.5 2007/08/02 00:05:40 squiz Exp $
14
 * @link      http://pear.php.net/package/PHP_CodeSniffer
15
 */
16
 
17
require_once 'PHPUnit/Framework/TestCase.php';
18
 
19
/**
20
 * Tests for the PHP_CodeSniffer:isCamelCaps method.
21
 *
22
 * @category  PHP
23
 * @package   PHP_CodeSniffer
24
 * @author    Greg Sherwood <gsherwood@squiz.net>
25
 * @author    Marc McIntyre <mmcintyre@squiz.net>
26
 * @copyright 2006 Squiz Pty Ltd (ABN 77 084 670 600)
27
 * @license   http://matrix.squiz.net/developer/tools/php_cs/licence BSD Licence
28
 * @version   Release: 1.2.0RC1
29
 * @link      http://pear.php.net/package/PHP_CodeSniffer
30
 */
31
class Core_IsCamelCapsTest extends PHPUnit_Framework_TestCase
32
{
33
 
34
 
35
    /**
36
     * Test valid public function/method names.
37
     *
38
     * @return void
39
     */
40
    public function testValidNotClassFormatPublic()
41
    {
42
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, true, true));
43
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, false));
44
 
45
    }//end testValidNotClassFormatPublic()
46
 
47
 
48
    /**
49
     * Test invalid public function/method names.
50
     *
51
     * @return void
52
     */
53
    public function testInvalidNotClassFormatPublic()
54
    {
55
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, true, true));
56
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisISCamelCaps', false, true, true));
57
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', false, true, true));
58
 
59
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, true, true));
60
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, true, true));
61
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, true, true));
62
 
63
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this*IsCamelCaps', false, true, true));
64
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this-IsCamelCaps', false, true, true));
65
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_IsCamelCaps', false, true, true));
66
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('this_is_camel_caps', false, true, true));
67
 
68
    }//end testInvalidNotClassFormatPublic()
69
 
70
 
71
    /**
72
     * Test valid private method names.
73
     *
74
     * @return void
75
     */
76
    public function testValidNotClassFormatPrivate()
77
    {
78
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisIsCamelCaps', false, false, true));
79
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, false));
80
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18N', false, false, true));
81
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('_i18n', false, false, true));
82
 
83
    }//end testValidNotClassFormatPrivate()
84
 
85
 
86
    /**
87
     * Test invalid private method names.
88
     *
89
     * @return void
90
     */
91
    public function testInvalidNotClassFormatPrivate()
92
    {
93
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', false, false, true));
94
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_thisISCamelCaps', false, false, true));
95
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', false, false, true));
96
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisIsCamelCaps', false, false, true));
97
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('__thisISCamelCaps', false, false, false));
98
 
99
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('3thisIsCamelCaps', false, false, true));
100
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('*thisIsCamelCaps', false, false, true));
101
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('-thisIsCamelCaps', false, false, true));
102
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_this_is_camel_caps', false, false, true));
103
 
104
    }//end testInvalidNotClassFormatPrivate()
105
 
106
 
107
    /**
108
     * Test valid class names.
109
     *
110
     * @return void
111
     */
112
    public function testValidClassFormatPublic()
113
    {
114
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisIsCamelCaps', true, true, true));
115
        $this->assertTrue(PHP_CodeSniffer::isCamelCaps('ThisISCamelCaps', true, true, false));
116
 
117
    }//end testValidClassFormatPublic()
118
 
119
 
120
    /**
121
     * Test invalid class names.
122
     *
123
     * @return void
124
     */
125
    public function testInvalidClassFormat()
126
    {
127
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('thisIsCamelCaps', true));
128
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This3IsCamelCaps', true));
129
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This-IsCamelCaps', true));
130
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('This_Is_Camel_Caps', true));
131
 
132
    }//end testInvalidClassFormat()
133
 
134
 
135
    /**
136
     * Test invalid class names with the private flag set.
137
     *
138
     * Note that the private flag is ignored if the class format
139
     * flag is set, so these names are all invalid.
140
     *
141
     * @return void
142
     */
143
    public function testInvalidClassFormatPrivate()
144
    {
145
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, true));
146
        $this->assertFalse(PHP_CodeSniffer::isCamelCaps('_ThisIsCamelCaps', true, false));
147
 
148
    }//end testInvalidClassFormatPrivate()
149
 
150
 
151
}//end class
152
 
153
?>