Completed
Push — develop ( 572bc7...60d03e )
by Zack
25:22 queued 04:21
created
vendor/squizlabs/php_codesniffer/tests/Standards/AllSniffs.php 1 patch
Indentation   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -18,106 +18,106 @@
 block discarded – undo
18 18
 {
19 19
 
20 20
 
21
-    /**
22
-     * Prepare the test runner.
23
-     *
24
-     * @return void
25
-     */
26
-    public static function main()
27
-    {
28
-        TestRunner::run(self::suite());
29
-
30
-    }//end main()
31
-
32
-
33
-    /**
34
-     * Add all sniff unit tests into a test suite.
35
-     *
36
-     * Sniff unit tests are found by recursing through the 'Tests' directory
37
-     * of each installed coding standard.
38
-     *
39
-     * @return \PHPUnit\Framework\TestSuite
40
-     */
41
-    public static function suite()
42
-    {
43
-        $GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']      = [];
44
-        $GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']    = [];
45
-        $GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = [];
46
-
47
-        $suite = new TestSuite('PHP CodeSniffer Standards');
48
-
49
-        $isInstalled = !is_file(__DIR__.'/../../autoload.php');
50
-
51
-        // Optionally allow for ignoring the tests for one or more standards.
52
-        $ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS');
53
-        if ($ignoreTestsForStandards === false) {
54
-            $ignoreTestsForStandards = [];
55
-        } else {
56
-            $ignoreTestsForStandards = explode(',', $ignoreTestsForStandards);
57
-        }
58
-
59
-        $installedStandards = self::getInstalledStandardDetails();
60
-
61
-        foreach ($installedStandards as $standard => $details) {
62
-            Autoload::addSearchPath($details['path'], $details['namespace']);
63
-
64
-            // If the test is running PEAR installed, the built-in standards
65
-            // are split into different directories; one for the sniffs and
66
-            // a different file system location for tests.
67
-            if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) {
68
-                $testPath = realpath(__DIR__.'/../../src/Standards/'.$standard);
69
-            } else {
70
-                $testPath = $details['path'];
71
-            }
72
-
73
-            if (in_array($standard, $ignoreTestsForStandards, true) === true) {
74
-                continue;
75
-            }
76
-
77
-            $testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR;
78
-            if (is_dir($testsDir) === false) {
79
-                // No tests for this standard.
80
-                continue;
81
-            }
82
-
83
-            $di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir));
84
-
85
-            foreach ($di as $file) {
86
-                // Skip hidden files.
87
-                if (substr($file->getFilename(), 0, 1) === '.') {
88
-                    continue;
89
-                }
90
-
91
-                // Tests must have the extension 'php'.
92
-                $parts = explode('.', $file);
93
-                $ext   = array_pop($parts);
94
-                if ($ext !== 'php') {
95
-                    continue;
96
-                }
97
-
98
-                $className = Autoload::loadFile($file->getPathname());
99
-                $GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path'];
100
-                $GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className]     = $testsDir;
101
-                $suite->addTestSuite($className);
102
-            }
103
-        }//end foreach
104
-
105
-        return $suite;
106
-
107
-    }//end suite()
108
-
109
-
110
-    /**
111
-     * Get the details of all coding standards installed.
112
-     *
113
-     * @return array
114
-     * @see    Standards::getInstalledStandardDetails()
115
-     */
116
-    protected static function getInstalledStandardDetails()
117
-    {
118
-        return Standards::getInstalledStandardDetails(true);
119
-
120
-    }//end getInstalledStandardDetails()
21
+	/**
22
+	 * Prepare the test runner.
23
+	 *
24
+	 * @return void
25
+	 */
26
+	public static function main()
27
+	{
28
+		TestRunner::run(self::suite());
29
+
30
+	}//end main()
31
+
32
+
33
+	/**
34
+	 * Add all sniff unit tests into a test suite.
35
+	 *
36
+	 * Sniff unit tests are found by recursing through the 'Tests' directory
37
+	 * of each installed coding standard.
38
+	 *
39
+	 * @return \PHPUnit\Framework\TestSuite
40
+	 */
41
+	public static function suite()
42
+	{
43
+		$GLOBALS['PHP_CODESNIFFER_SNIFF_CODES']      = [];
44
+		$GLOBALS['PHP_CODESNIFFER_FIXABLE_CODES']    = [];
45
+		$GLOBALS['PHP_CODESNIFFER_SNIFF_CASE_FILES'] = [];
46
+
47
+		$suite = new TestSuite('PHP CodeSniffer Standards');
48
+
49
+		$isInstalled = !is_file(__DIR__.'/../../autoload.php');
50
+
51
+		// Optionally allow for ignoring the tests for one or more standards.
52
+		$ignoreTestsForStandards = getenv('PHPCS_IGNORE_TESTS');
53
+		if ($ignoreTestsForStandards === false) {
54
+			$ignoreTestsForStandards = [];
55
+		} else {
56
+			$ignoreTestsForStandards = explode(',', $ignoreTestsForStandards);
57
+		}
58
+
59
+		$installedStandards = self::getInstalledStandardDetails();
60
+
61
+		foreach ($installedStandards as $standard => $details) {
62
+			Autoload::addSearchPath($details['path'], $details['namespace']);
63
+
64
+			// If the test is running PEAR installed, the built-in standards
65
+			// are split into different directories; one for the sniffs and
66
+			// a different file system location for tests.
67
+			if ($isInstalled === true && is_dir(dirname($details['path']).DIRECTORY_SEPARATOR.'Generic') === true) {
68
+				$testPath = realpath(__DIR__.'/../../src/Standards/'.$standard);
69
+			} else {
70
+				$testPath = $details['path'];
71
+			}
72
+
73
+			if (in_array($standard, $ignoreTestsForStandards, true) === true) {
74
+				continue;
75
+			}
76
+
77
+			$testsDir = $testPath.DIRECTORY_SEPARATOR.'Tests'.DIRECTORY_SEPARATOR;
78
+			if (is_dir($testsDir) === false) {
79
+				// No tests for this standard.
80
+				continue;
81
+			}
82
+
83
+			$di = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($testsDir));
84
+
85
+			foreach ($di as $file) {
86
+				// Skip hidden files.
87
+				if (substr($file->getFilename(), 0, 1) === '.') {
88
+					continue;
89
+				}
90
+
91
+				// Tests must have the extension 'php'.
92
+				$parts = explode('.', $file);
93
+				$ext   = array_pop($parts);
94
+				if ($ext !== 'php') {
95
+					continue;
96
+				}
97
+
98
+				$className = Autoload::loadFile($file->getPathname());
99
+				$GLOBALS['PHP_CODESNIFFER_STANDARD_DIRS'][$className] = $details['path'];
100
+				$GLOBALS['PHP_CODESNIFFER_TEST_DIRS'][$className]     = $testsDir;
101
+				$suite->addTestSuite($className);
102
+			}
103
+		}//end foreach
104
+
105
+		return $suite;
106
+
107
+	}//end suite()
108
+
109
+
110
+	/**
111
+	 * Get the details of all coding standards installed.
112
+	 *
113
+	 * @return array
114
+	 * @see    Standards::getInstalledStandardDetails()
115
+	 */
116
+	protected static function getInstalledStandardDetails()
117
+	{
118
+		return Standards::getInstalledStandardDetails(true);
119
+
120
+	}//end getInstalledStandardDetails()
121 121
 
122 122
 
123 123
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/tests/Core/IsCamelCapsTest.php 1 patch
Indentation   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -16,120 +16,120 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * Test valid public function/method names.
21
-     *
22
-     * @return void
23
-     */
24
-    public function testValidNotClassFormatPublic()
25
-    {
26
-        $this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true));
27
-        $this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false));
28
-
29
-    }//end testValidNotClassFormatPublic()
30
-
31
-
32
-    /**
33
-     * Test invalid public function/method names.
34
-     *
35
-     * @return void
36
-     */
37
-    public function testInvalidNotClassFormatPublic()
38
-    {
39
-        $this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true));
40
-        $this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true));
41
-        $this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true));
42
-
43
-        $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, true, true));
44
-        $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, true, true));
45
-        $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, true, true));
46
-
47
-        $this->assertFalse(Common::isCamelCaps('this*IsCamelCaps', false, true, true));
48
-        $this->assertFalse(Common::isCamelCaps('this-IsCamelCaps', false, true, true));
49
-        $this->assertFalse(Common::isCamelCaps('this_IsCamelCaps', false, true, true));
50
-        $this->assertFalse(Common::isCamelCaps('this_is_camel_caps', false, true, true));
51
-
52
-    }//end testInvalidNotClassFormatPublic()
53
-
54
-
55
-    /**
56
-     * Test valid private method names.
57
-     *
58
-     * @return void
59
-     */
60
-    public function testValidNotClassFormatPrivate()
61
-    {
62
-        $this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true));
63
-        $this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false));
64
-        $this->assertTrue(Common::isCamelCaps('_i18N', false, false, true));
65
-        $this->assertTrue(Common::isCamelCaps('_i18n', false, false, true));
66
-
67
-    }//end testValidNotClassFormatPrivate()
68
-
69
-
70
-    /**
71
-     * Test invalid private method names.
72
-     *
73
-     * @return void
74
-     */
75
-    public function testInvalidNotClassFormatPrivate()
76
-    {
77
-        $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true));
78
-        $this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true));
79
-        $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true));
80
-        $this->assertFalse(Common::isCamelCaps('__thisIsCamelCaps', false, false, true));
81
-        $this->assertFalse(Common::isCamelCaps('__thisISCamelCaps', false, false, false));
82
-
83
-        $this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, false, true));
84
-        $this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, false, true));
85
-        $this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, false, true));
86
-        $this->assertFalse(Common::isCamelCaps('_this_is_camel_caps', false, false, true));
87
-
88
-    }//end testInvalidNotClassFormatPrivate()
89
-
90
-
91
-    /**
92
-     * Test valid class names.
93
-     *
94
-     * @return void
95
-     */
96
-    public function testValidClassFormatPublic()
97
-    {
98
-        $this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true));
99
-        $this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false));
100
-        $this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false));
101
-
102
-    }//end testValidClassFormatPublic()
103
-
104
-
105
-    /**
106
-     * Test invalid class names.
107
-     *
108
-     * @return void
109
-     */
110
-    public function testInvalidClassFormat()
111
-    {
112
-        $this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true));
113
-        $this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true));
114
-        $this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true));
115
-
116
-    }//end testInvalidClassFormat()
117
-
118
-
119
-    /**
120
-     * Test invalid class names with the private flag set.
121
-     *
122
-     * Note that the private flag is ignored if the class format
123
-     * flag is set, so these names are all invalid.
124
-     *
125
-     * @return void
126
-     */
127
-    public function testInvalidClassFormatPrivate()
128
-    {
129
-        $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true));
130
-        $this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false));
131
-
132
-    }//end testInvalidClassFormatPrivate()
19
+	/**
20
+	 * Test valid public function/method names.
21
+	 *
22
+	 * @return void
23
+	 */
24
+	public function testValidNotClassFormatPublic()
25
+	{
26
+		$this->assertTrue(Common::isCamelCaps('thisIsCamelCaps', false, true, true));
27
+		$this->assertTrue(Common::isCamelCaps('thisISCamelCaps', false, true, false));
28
+
29
+	}//end testValidNotClassFormatPublic()
30
+
31
+
32
+	/**
33
+	 * Test invalid public function/method names.
34
+	 *
35
+	 * @return void
36
+	 */
37
+	public function testInvalidNotClassFormatPublic()
38
+	{
39
+		$this->assertFalse(Common::isCamelCaps('_thisIsCamelCaps', false, true, true));
40
+		$this->assertFalse(Common::isCamelCaps('thisISCamelCaps', false, true, true));
41
+		$this->assertFalse(Common::isCamelCaps('ThisIsCamelCaps', false, true, true));
42
+
43
+		$this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, true, true));
44
+		$this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, true, true));
45
+		$this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, true, true));
46
+
47
+		$this->assertFalse(Common::isCamelCaps('this*IsCamelCaps', false, true, true));
48
+		$this->assertFalse(Common::isCamelCaps('this-IsCamelCaps', false, true, true));
49
+		$this->assertFalse(Common::isCamelCaps('this_IsCamelCaps', false, true, true));
50
+		$this->assertFalse(Common::isCamelCaps('this_is_camel_caps', false, true, true));
51
+
52
+	}//end testInvalidNotClassFormatPublic()
53
+
54
+
55
+	/**
56
+	 * Test valid private method names.
57
+	 *
58
+	 * @return void
59
+	 */
60
+	public function testValidNotClassFormatPrivate()
61
+	{
62
+		$this->assertTrue(Common::isCamelCaps('_thisIsCamelCaps', false, false, true));
63
+		$this->assertTrue(Common::isCamelCaps('_thisISCamelCaps', false, false, false));
64
+		$this->assertTrue(Common::isCamelCaps('_i18N', false, false, true));
65
+		$this->assertTrue(Common::isCamelCaps('_i18n', false, false, true));
66
+
67
+	}//end testValidNotClassFormatPrivate()
68
+
69
+
70
+	/**
71
+	 * Test invalid private method names.
72
+	 *
73
+	 * @return void
74
+	 */
75
+	public function testInvalidNotClassFormatPrivate()
76
+	{
77
+		$this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', false, false, true));
78
+		$this->assertFalse(Common::isCamelCaps('_thisISCamelCaps', false, false, true));
79
+		$this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', false, false, true));
80
+		$this->assertFalse(Common::isCamelCaps('__thisIsCamelCaps', false, false, true));
81
+		$this->assertFalse(Common::isCamelCaps('__thisISCamelCaps', false, false, false));
82
+
83
+		$this->assertFalse(Common::isCamelCaps('3thisIsCamelCaps', false, false, true));
84
+		$this->assertFalse(Common::isCamelCaps('*thisIsCamelCaps', false, false, true));
85
+		$this->assertFalse(Common::isCamelCaps('-thisIsCamelCaps', false, false, true));
86
+		$this->assertFalse(Common::isCamelCaps('_this_is_camel_caps', false, false, true));
87
+
88
+	}//end testInvalidNotClassFormatPrivate()
89
+
90
+
91
+	/**
92
+	 * Test valid class names.
93
+	 *
94
+	 * @return void
95
+	 */
96
+	public function testValidClassFormatPublic()
97
+	{
98
+		$this->assertTrue(Common::isCamelCaps('ThisIsCamelCaps', true, true, true));
99
+		$this->assertTrue(Common::isCamelCaps('ThisISCamelCaps', true, true, false));
100
+		$this->assertTrue(Common::isCamelCaps('This3IsCamelCaps', true, true, false));
101
+
102
+	}//end testValidClassFormatPublic()
103
+
104
+
105
+	/**
106
+	 * Test invalid class names.
107
+	 *
108
+	 * @return void
109
+	 */
110
+	public function testInvalidClassFormat()
111
+	{
112
+		$this->assertFalse(Common::isCamelCaps('thisIsCamelCaps', true));
113
+		$this->assertFalse(Common::isCamelCaps('This-IsCamelCaps', true));
114
+		$this->assertFalse(Common::isCamelCaps('This_Is_Camel_Caps', true));
115
+
116
+	}//end testInvalidClassFormat()
117
+
118
+
119
+	/**
120
+	 * Test invalid class names with the private flag set.
121
+	 *
122
+	 * Note that the private flag is ignored if the class format
123
+	 * flag is set, so these names are all invalid.
124
+	 *
125
+	 * @return void
126
+	 */
127
+	public function testInvalidClassFormatPrivate()
128
+	{
129
+		$this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, true));
130
+		$this->assertFalse(Common::isCamelCaps('_ThisIsCamelCaps', true, false));
131
+
132
+	}//end testInvalidClassFormatPrivate()
133 133
 
134 134
 
135 135
 }//end class
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.inc 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -18,8 +18,8 @@
 block discarded – undo
18 18
 
19 19
 /* testSwitch */
20 20
 switch ($a) {
21
-    case 1: {break;}
22
-    default: {break;}
21
+	case 1: {break;}
22
+	default: {break;}
23 23
 }
24 24
 
25 25
 /* testStatementAsArrayValue */
Please login to merge, or discard this patch.
vendor/squizlabs/php_codesniffer/tests/Core/File/FindEndOfStatementTest.php 1 patch
Indentation   +156 added lines, -156 removed lines patch added patch discarded remove patch
@@ -17,187 +17,187 @@
 block discarded – undo
17 17
 class FindEndOfStatementTest extends TestCase
18 18
 {
19 19
 
20
-    /**
21
-     * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
-     *
23
-     * @var \PHP_CodeSniffer\Files\File
24
-     */
25
-    private $phpcsFile;
26
-
27
-
28
-    /**
29
-     * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
-     *
31
-     * Methods used for these tests can be found in a test case file in the same
32
-     * directory and with the same name, using the .inc extension.
33
-     *
34
-     * @return void
35
-     */
36
-    public function setUp()
37
-    {
38
-        $config            = new Config();
39
-        $config->standards = ['Generic'];
20
+	/**
21
+	 * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
+	 *
23
+	 * @var \PHP_CodeSniffer\Files\File
24
+	 */
25
+	private $phpcsFile;
26
+
27
+
28
+	/**
29
+	 * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
+	 *
31
+	 * Methods used for these tests can be found in a test case file in the same
32
+	 * directory and with the same name, using the .inc extension.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function setUp()
37
+	{
38
+		$config            = new Config();
39
+		$config->standards = ['Generic'];
40 40
 
41
-        $ruleset = new Ruleset($config);
41
+		$ruleset = new Ruleset($config);
42 42
 
43
-        $pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
-        $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
-        $this->phpcsFile->process();
46
-
47
-    }//end setUp()
48
-
49
-
50
-    /**
51
-     * Clean up after finished test.
52
-     *
53
-     * @return void
54
-     */
55
-    public function tearDown()
56
-    {
57
-        unset($this->phpcsFile);
58
-
59
-    }//end tearDown()
60
-
61
-
62
-    /**
63
-     * Test a simple assignment.
64
-     *
65
-     * @return void
66
-     */
67
-    public function testSimpleAssignment()
68
-    {
69
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSimpleAssignment */') + 2);
70
-        $found = $this->phpcsFile->findEndOfStatement($start);
43
+		$pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+		$this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+		$this->phpcsFile->process();
46
+
47
+	}//end setUp()
48
+
49
+
50
+	/**
51
+	 * Clean up after finished test.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function tearDown()
56
+	{
57
+		unset($this->phpcsFile);
58
+
59
+	}//end tearDown()
60
+
61
+
62
+	/**
63
+	 * Test a simple assignment.
64
+	 *
65
+	 * @return void
66
+	 */
67
+	public function testSimpleAssignment()
68
+	{
69
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSimpleAssignment */') + 2);
70
+		$found = $this->phpcsFile->findEndOfStatement($start);
71 71
 
72
-        $tokens = $this->phpcsFile->getTokens();
73
-        $this->assertSame($tokens[($start + 5)], $tokens[$found]);
72
+		$tokens = $this->phpcsFile->getTokens();
73
+		$this->assertSame($tokens[($start + 5)], $tokens[$found]);
74 74
 
75
-    }//end testSimpleAssignment()
76
-
77
-
78
-    /**
79
-     * Test a direct call to a control structure.
80
-     *
81
-     * @return void
82
-     */
83
-    public function testControlStructure()
84
-    {
85
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testControlStructure */') + 2);
86
-        $found = $this->phpcsFile->findEndOfStatement($start);
87
-
88
-        $tokens = $this->phpcsFile->getTokens();
89
-        $this->assertSame($tokens[($start + 6)], $tokens[$found]);
90
-
91
-    }//end testControlStructure()
92
-
93
-
94
-    /**
95
-     * Test the assignment of a closure.
96
-     *
97
-     * @return void
98
-     */
99
-    public function testClosureAssignment()
100
-    {
101
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testClosureAssignment */') + 2);
102
-        $found = $this->phpcsFile->findEndOfStatement($start);
103
-
104
-        $tokens = $this->phpcsFile->getTokens();
105
-        $this->assertSame($tokens[($start + 13)], $tokens[$found]);
106
-
107
-    }//end testClosureAssignment()
108
-
109
-
110
-    /**
111
-     * Test using a heredoc in a function argument.
112
-     *
113
-     * @return void
114
-     */
115
-    public function testHeredocFunctionArg()
116
-    {
117
-        // Find the end of the function.
118
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testHeredocFunctionArg */') + 2);
119
-        $found = $this->phpcsFile->findEndOfStatement($start);
120
-
121
-        $tokens = $this->phpcsFile->getTokens();
122
-        $this->assertSame($tokens[($start + 10)], $tokens[$found]);
75
+	}//end testSimpleAssignment()
76
+
77
+
78
+	/**
79
+	 * Test a direct call to a control structure.
80
+	 *
81
+	 * @return void
82
+	 */
83
+	public function testControlStructure()
84
+	{
85
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testControlStructure */') + 2);
86
+		$found = $this->phpcsFile->findEndOfStatement($start);
87
+
88
+		$tokens = $this->phpcsFile->getTokens();
89
+		$this->assertSame($tokens[($start + 6)], $tokens[$found]);
90
+
91
+	}//end testControlStructure()
92
+
93
+
94
+	/**
95
+	 * Test the assignment of a closure.
96
+	 *
97
+	 * @return void
98
+	 */
99
+	public function testClosureAssignment()
100
+	{
101
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testClosureAssignment */') + 2);
102
+		$found = $this->phpcsFile->findEndOfStatement($start);
103
+
104
+		$tokens = $this->phpcsFile->getTokens();
105
+		$this->assertSame($tokens[($start + 13)], $tokens[$found]);
106
+
107
+	}//end testClosureAssignment()
108
+
109
+
110
+	/**
111
+	 * Test using a heredoc in a function argument.
112
+	 *
113
+	 * @return void
114
+	 */
115
+	public function testHeredocFunctionArg()
116
+	{
117
+		// Find the end of the function.
118
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testHeredocFunctionArg */') + 2);
119
+		$found = $this->phpcsFile->findEndOfStatement($start);
120
+
121
+		$tokens = $this->phpcsFile->getTokens();
122
+		$this->assertSame($tokens[($start + 10)], $tokens[$found]);
123 123
 
124
-        // Find the end of the heredoc.
125
-        $start += 2;
126
-        $found  = $this->phpcsFile->findEndOfStatement($start);
124
+		// Find the end of the heredoc.
125
+		$start += 2;
126
+		$found  = $this->phpcsFile->findEndOfStatement($start);
127 127
 
128
-        $tokens = $this->phpcsFile->getTokens();
129
-        $this->assertSame($tokens[($start + 4)], $tokens[$found]);
128
+		$tokens = $this->phpcsFile->getTokens();
129
+		$this->assertSame($tokens[($start + 4)], $tokens[$found]);
130 130
 
131
-        // Find the end of the last arg.
132
-        $start = ($found + 2);
133
-        $found = $this->phpcsFile->findEndOfStatement($start);
131
+		// Find the end of the last arg.
132
+		$start = ($found + 2);
133
+		$found = $this->phpcsFile->findEndOfStatement($start);
134 134
 
135
-        $tokens = $this->phpcsFile->getTokens();
136
-        $this->assertSame($tokens[$start], $tokens[$found]);
135
+		$tokens = $this->phpcsFile->getTokens();
136
+		$this->assertSame($tokens[$start], $tokens[$found]);
137 137
 
138
-    }//end testHeredocFunctionArg()
138
+	}//end testHeredocFunctionArg()
139 139
 
140 140
 
141
-    /**
142
-     * Test parts of a switch statement.
143
-     *
144
-     * @return void
145
-     */
146
-    public function testSwitch()
147
-    {
148
-        // Find the end of the switch.
149
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSwitch */') + 2);
150
-        $found = $this->phpcsFile->findEndOfStatement($start);
141
+	/**
142
+	 * Test parts of a switch statement.
143
+	 *
144
+	 * @return void
145
+	 */
146
+	public function testSwitch()
147
+	{
148
+		// Find the end of the switch.
149
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testSwitch */') + 2);
150
+		$found = $this->phpcsFile->findEndOfStatement($start);
151 151
 
152
-        $tokens = $this->phpcsFile->getTokens();
153
-        $this->assertSame($tokens[($start + 28)], $tokens[$found]);
152
+		$tokens = $this->phpcsFile->getTokens();
153
+		$this->assertSame($tokens[($start + 28)], $tokens[$found]);
154 154
 
155
-        // Find the end of the case.
156
-        $start += 9;
157
-        $found  = $this->phpcsFile->findEndOfStatement($start);
155
+		// Find the end of the case.
156
+		$start += 9;
157
+		$found  = $this->phpcsFile->findEndOfStatement($start);
158 158
 
159
-        $tokens = $this->phpcsFile->getTokens();
160
-        $this->assertSame($tokens[($start + 8)], $tokens[$found]);
159
+		$tokens = $this->phpcsFile->getTokens();
160
+		$this->assertSame($tokens[($start + 8)], $tokens[$found]);
161 161
 
162
-        // Find the end of default case.
163
-        $start += 11;
164
-        $found  = $this->phpcsFile->findEndOfStatement($start);
162
+		// Find the end of default case.
163
+		$start += 11;
164
+		$found  = $this->phpcsFile->findEndOfStatement($start);
165 165
 
166
-        $tokens = $this->phpcsFile->getTokens();
167
-        $this->assertSame($tokens[($start + 6)], $tokens[$found]);
166
+		$tokens = $this->phpcsFile->getTokens();
167
+		$this->assertSame($tokens[($start + 6)], $tokens[$found]);
168 168
 
169
-    }//end testSwitch()
169
+	}//end testSwitch()
170 170
 
171 171
 
172
-    /**
173
-     * Test statements that are array values.
174
-     *
175
-     * @return void
176
-     */
177
-    public function testStatementAsArrayValue()
178
-    {
179
-        // Test short array syntax.
180
-        $start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testStatementAsArrayValue */') + 7);
181
-        $found = $this->phpcsFile->findEndOfStatement($start);
172
+	/**
173
+	 * Test statements that are array values.
174
+	 *
175
+	 * @return void
176
+	 */
177
+	public function testStatementAsArrayValue()
178
+	{
179
+		// Test short array syntax.
180
+		$start = ($this->phpcsFile->findNext(T_COMMENT, 0, null, false, '/* testStatementAsArrayValue */') + 7);
181
+		$found = $this->phpcsFile->findEndOfStatement($start);
182 182
 
183
-        $tokens = $this->phpcsFile->getTokens();
184
-        $this->assertSame($tokens[($start + 2)], $tokens[$found]);
183
+		$tokens = $this->phpcsFile->getTokens();
184
+		$this->assertSame($tokens[($start + 2)], $tokens[$found]);
185 185
 
186
-        // Test long array syntax.
187
-        $start += 12;
188
-        $found  = $this->phpcsFile->findEndOfStatement($start);
186
+		// Test long array syntax.
187
+		$start += 12;
188
+		$found  = $this->phpcsFile->findEndOfStatement($start);
189 189
 
190
-        $tokens = $this->phpcsFile->getTokens();
191
-        $this->assertSame($tokens[($start + 2)], $tokens[$found]);
190
+		$tokens = $this->phpcsFile->getTokens();
191
+		$this->assertSame($tokens[($start + 2)], $tokens[$found]);
192 192
 
193
-        // Test same statement outside of array.
194
-        $start += 10;
195
-        $found  = $this->phpcsFile->findEndOfStatement($start);
193
+		// Test same statement outside of array.
194
+		$start += 10;
195
+		$found  = $this->phpcsFile->findEndOfStatement($start);
196 196
 
197
-        $tokens = $this->phpcsFile->getTokens();
198
-        $this->assertSame($tokens[($start + 3)], $tokens[$found]);
197
+		$tokens = $this->phpcsFile->getTokens();
198
+		$this->assertSame($tokens[($start + 3)], $tokens[$found]);
199 199
 
200
-    }//end testStatementAsArrayValue()
200
+	}//end testStatementAsArrayValue()
201 201
 
202 202
 
203 203
 }//end class
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.inc 1 patch
Indentation   +95 added lines, -95 removed lines patch added patch discarded remove patch
@@ -2,113 +2,113 @@
 block discarded – undo
2 2
 
3 3
 class TestMemberProperties
4 4
 {
5
-    /* testVar */
6
-    var $varA = true;
7
-
8
-    /* testPublic */
9
-    public $varB = true;
10
-
11
-    /* testProtected */
12
-    protected $varC = true;
13
-
14
-    /* testPrivate */
15
-    private $varD = true;
16
-
17
-    /* testStatic */
18
-    static $varE = true;
19
-
20
-    /* testStaticVar */
21
-    static var $varF = true;
22
-
23
-    /* testVarStatic */
24
-    var static $varG = true;
25
-
26
-    /* testPublicStatic */
27
-    public static $varH = true;
28
-
29
-    /* testProtectedStatic */
30
-    static protected $varI = true;
31
-
32
-    /* testPrivateStatic */
33
-    private static $varJ = true;
34
-
35
-    /* testNoPrefix */
36
-    $varK = true;
37
-
38
-    /* testPublicStaticWithDocblock */
39
-    /**
40
-     * Comment here.
41
-     *
42
-     * @phpcs:ignore Standard.Category.Sniff -- because
43
-     * @var boolean
44
-     */
45
-    public static $varH = true;
46
-
47
-    /* testProtectedStaticWithDocblock */
48
-    /**
49
-     * Comment here.
50
-     *
51
-     * @phpcs:ignore Standard.Category.Sniff -- because
52
-     * @var boolean
53
-     */
54
-    static protected $varI = true;
55
-
56
-    /* testPrivateStaticWithDocblock */
57
-    /**
58
-     * Comment here.
59
-     *
60
-     * @phpcs:ignore Standard.Category.Sniff -- because
61
-     * @var boolean
62
-     */
63
-    private static $varJ = true;
64
-
65
-
66
-    protected static
67
-        /* testGroupProtectedStatic 1 */
68
-        $varL,
69
-        /* testGroupProtectedStatic 2 */
70
-        $varM,
71
-        /* testGroupProtectedStatic 3 */
72
-        $varN;
73
-
74
-    private
75
-        /* testGroupPrivate 1 */
76
-        $varO = true,
77
-        /* testGroupPrivate 2 */
78
-        $varP = array( 'a' => 'a', 'b' => 'b' ),
79
-        /* testGroupPrivate 3 */
80
-        $varQ = 'string',
81
-        /* testGroupPrivate 4 */
82
-        $varR = 123,
83
-        /* testGroupPrivate 5 */
84
-        $varS = ONE / self::THREE,
85
-        /* testGroupPrivate 6 */
86
-        $varT = [
5
+	/* testVar */
6
+	var $varA = true;
7
+
8
+	/* testPublic */
9
+	public $varB = true;
10
+
11
+	/* testProtected */
12
+	protected $varC = true;
13
+
14
+	/* testPrivate */
15
+	private $varD = true;
16
+
17
+	/* testStatic */
18
+	static $varE = true;
19
+
20
+	/* testStaticVar */
21
+	static var $varF = true;
22
+
23
+	/* testVarStatic */
24
+	var static $varG = true;
25
+
26
+	/* testPublicStatic */
27
+	public static $varH = true;
28
+
29
+	/* testProtectedStatic */
30
+	static protected $varI = true;
31
+
32
+	/* testPrivateStatic */
33
+	private static $varJ = true;
34
+
35
+	/* testNoPrefix */
36
+	$varK = true;
37
+
38
+	/* testPublicStaticWithDocblock */
39
+	/**
40
+	 * Comment here.
41
+	 *
42
+	 * @phpcs:ignore Standard.Category.Sniff -- because
43
+	 * @var boolean
44
+	 */
45
+	public static $varH = true;
46
+
47
+	/* testProtectedStaticWithDocblock */
48
+	/**
49
+	 * Comment here.
50
+	 *
51
+	 * @phpcs:ignore Standard.Category.Sniff -- because
52
+	 * @var boolean
53
+	 */
54
+	static protected $varI = true;
55
+
56
+	/* testPrivateStaticWithDocblock */
57
+	/**
58
+	 * Comment here.
59
+	 *
60
+	 * @phpcs:ignore Standard.Category.Sniff -- because
61
+	 * @var boolean
62
+	 */
63
+	private static $varJ = true;
64
+
65
+
66
+	protected static
67
+		/* testGroupProtectedStatic 1 */
68
+		$varL,
69
+		/* testGroupProtectedStatic 2 */
70
+		$varM,
71
+		/* testGroupProtectedStatic 3 */
72
+		$varN;
73
+
74
+	private
75
+		/* testGroupPrivate 1 */
76
+		$varO = true,
77
+		/* testGroupPrivate 2 */
78
+		$varP = array( 'a' => 'a', 'b' => 'b' ),
79
+		/* testGroupPrivate 3 */
80
+		$varQ = 'string',
81
+		/* testGroupPrivate 4 */
82
+		$varR = 123,
83
+		/* testGroupPrivate 5 */
84
+		$varS = ONE / self::THREE,
85
+		/* testGroupPrivate 6 */
86
+		$varT = [
87 87
 			'a' => 'a',
88 88
 			'b' => 'b'
89 89
 		],
90
-        /* testGroupPrivate 7 */
91
-        $varU = __DIR__ . "/base";
90
+		/* testGroupPrivate 7 */
91
+		$varU = __DIR__ . "/base";
92 92
 
93 93
 
94
-    /* testMethodParam */
95
-    public function methodName($param) {
96
-        /* testImportedGlobal */
97
-        global $importedGlobal = true;
94
+	/* testMethodParam */
95
+	public function methodName($param) {
96
+		/* testImportedGlobal */
97
+		global $importedGlobal = true;
98 98
 
99
-        /* testLocalVariable */
100
-        $localVariable = true;
101
-    }
99
+		/* testLocalVariable */
100
+		$localVariable = true;
101
+	}
102 102
 
103
-    /* testPropertyAfterMethod */
104
-    private static $varV = true;
103
+	/* testPropertyAfterMethod */
104
+	private static $varV = true;
105 105
 
106 106
 }
107 107
 
108 108
 interface Base
109 109
 {
110
-    /* testInterfaceProperty */
111
-    protected $anonymous;
110
+	/* testInterfaceProperty */
111
+	protected $anonymous;
112 112
 }
113 113
 
114 114
 /* testGlobalVariable */
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/tests/Core/File/GetMemberPropertiesTest.php 1 patch
Indentation   +378 added lines, -378 removed lines patch added patch discarded remove patch
@@ -17,384 +17,384 @@
 block discarded – undo
17 17
 class GetMemberPropertiesTest extends TestCase
18 18
 {
19 19
 
20
-    /**
21
-     * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
-     *
23
-     * @var \PHP_CodeSniffer\Files\File
24
-     */
25
-    private $phpcsFile;
26
-
27
-
28
-    /**
29
-     * Initialize & tokenize PHP_CodeSniffer_File with code from the test case file.
30
-     *
31
-     * Methods used for these tests can be found in a test case file in the same
32
-     * directory and with the same name, using the .inc extension.
33
-     *
34
-     * @return void
35
-     */
36
-    public function setUp()
37
-    {
38
-        $config            = new Config();
39
-        $config->standards = ['Generic'];
40
-
41
-        $ruleset = new Ruleset($config);
42
-
43
-        $pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
-        $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
-        $this->phpcsFile->process();
46
-
47
-    }//end setUp()
48
-
49
-
50
-    /**
51
-     * Clean up after finished test.
52
-     *
53
-     * @return void
54
-     */
55
-    public function tearDown()
56
-    {
57
-        unset($this->phpcsFile);
58
-
59
-    }//end tearDown()
60
-
61
-
62
-    /**
63
-     * Test the getMemberProperties() method.
64
-     *
65
-     * @param string $identifier Comment which precedes the test case.
66
-     * @param bool   $expected   Expected function output.
67
-     *
68
-     * @dataProvider dataGetMemberProperties
69
-     *
70
-     * @return void
71
-     */
72
-    public function testGetMemberProperties($identifier, $expected)
73
-    {
74
-        $start    = ($this->phpcsFile->numTokens - 1);
75
-        $delim    = $this->phpcsFile->findPrevious(
76
-            T_COMMENT,
77
-            $start,
78
-            null,
79
-            false,
80
-            $identifier
81
-        );
82
-        $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
83
-
84
-        $result = $this->phpcsFile->getMemberProperties($variable);
85
-        $this->assertSame($expected, $result);
86
-
87
-    }//end testGetMemberProperties()
88
-
89
-
90
-    /**
91
-     * Data provider for the GetMemberProperties test.
92
-     *
93
-     * @see testGetMemberProperties()
94
-     *
95
-     * @return array
96
-     */
97
-    public function dataGetMemberProperties()
98
-    {
99
-        return [
100
-            [
101
-                '/* testVar */',
102
-                [
103
-                    'scope'           => 'public',
104
-                    'scope_specified' => false,
105
-                    'is_static'       => false,
106
-                ],
107
-            ],
108
-            [
109
-                '/* testPublic */',
110
-                [
111
-                    'scope'           => 'public',
112
-                    'scope_specified' => true,
113
-                    'is_static'       => false,
114
-                ],
115
-            ],
116
-            [
117
-                '/* testProtected */',
118
-                [
119
-                    'scope'           => 'protected',
120
-                    'scope_specified' => true,
121
-                    'is_static'       => false,
122
-                ],
123
-            ],
124
-            [
125
-                '/* testPrivate */',
126
-                [
127
-                    'scope'           => 'private',
128
-                    'scope_specified' => true,
129
-                    'is_static'       => false,
130
-                ],
131
-            ],
132
-            [
133
-                '/* testStatic */',
134
-                [
135
-                    'scope'           => 'public',
136
-                    'scope_specified' => false,
137
-                    'is_static'       => true,
138
-                ],
139
-            ],
140
-            [
141
-                '/* testStaticVar */',
142
-                [
143
-                    'scope'           => 'public',
144
-                    'scope_specified' => false,
145
-                    'is_static'       => true,
146
-                ],
147
-            ],
148
-            [
149
-                '/* testVarStatic */',
150
-                [
151
-                    'scope'           => 'public',
152
-                    'scope_specified' => false,
153
-                    'is_static'       => true,
154
-                ],
155
-            ],
156
-            [
157
-                '/* testPublicStatic */',
158
-                [
159
-                    'scope'           => 'public',
160
-                    'scope_specified' => true,
161
-                    'is_static'       => true,
162
-                ],
163
-            ],
164
-            [
165
-                '/* testProtectedStatic */',
166
-                [
167
-                    'scope'           => 'protected',
168
-                    'scope_specified' => true,
169
-                    'is_static'       => true,
170
-                ],
171
-            ],
172
-            [
173
-                '/* testPrivateStatic */',
174
-                [
175
-                    'scope'           => 'private',
176
-                    'scope_specified' => true,
177
-                    'is_static'       => true,
178
-                ],
179
-            ],
180
-            [
181
-                '/* testPublicStaticWithDocblock */',
182
-                [
183
-                    'scope'           => 'public',
184
-                    'scope_specified' => true,
185
-                    'is_static'       => true,
186
-                ],
187
-            ],
188
-            [
189
-                '/* testProtectedStaticWithDocblock */',
190
-                [
191
-                    'scope'           => 'protected',
192
-                    'scope_specified' => true,
193
-                    'is_static'       => true,
194
-                ],
195
-            ],
196
-            [
197
-                '/* testPrivateStaticWithDocblock */',
198
-                [
199
-                    'scope'           => 'private',
200
-                    'scope_specified' => true,
201
-                    'is_static'       => true,
202
-                ],
203
-            ],
204
-            [
205
-                '/* testNoPrefix */',
206
-                [
207
-                    'scope'           => 'public',
208
-                    'scope_specified' => false,
209
-                    'is_static'       => false,
210
-                ],
211
-            ],
212
-            [
213
-                '/* testGroupProtectedStatic 1 */',
214
-                [
215
-                    'scope'           => 'protected',
216
-                    'scope_specified' => true,
217
-                    'is_static'       => true,
218
-                ],
219
-            ],
220
-            [
221
-                '/* testGroupProtectedStatic 2 */',
222
-                [
223
-                    'scope'           => 'protected',
224
-                    'scope_specified' => true,
225
-                    'is_static'       => true,
226
-                ],
227
-            ],
228
-            [
229
-                '/* testGroupProtectedStatic 3 */',
230
-                [
231
-                    'scope'           => 'protected',
232
-                    'scope_specified' => true,
233
-                    'is_static'       => true,
234
-                ],
235
-            ],
236
-            [
237
-                '/* testGroupPrivate 1 */',
238
-                [
239
-                    'scope'           => 'private',
240
-                    'scope_specified' => true,
241
-                    'is_static'       => false,
242
-                ],
243
-            ],
244
-            [
245
-                '/* testGroupPrivate 2 */',
246
-                [
247
-                    'scope'           => 'private',
248
-                    'scope_specified' => true,
249
-                    'is_static'       => false,
250
-                ],
251
-            ],
252
-            [
253
-                '/* testGroupPrivate 3 */',
254
-                [
255
-                    'scope'           => 'private',
256
-                    'scope_specified' => true,
257
-                    'is_static'       => false,
258
-                ],
259
-            ],
260
-            [
261
-                '/* testGroupPrivate 4 */',
262
-                [
263
-                    'scope'           => 'private',
264
-                    'scope_specified' => true,
265
-                    'is_static'       => false,
266
-                ],
267
-            ],
268
-            [
269
-                '/* testGroupPrivate 5 */',
270
-                [
271
-                    'scope'           => 'private',
272
-                    'scope_specified' => true,
273
-                    'is_static'       => false,
274
-                ],
275
-            ],
276
-            [
277
-                '/* testGroupPrivate 6 */',
278
-                [
279
-                    'scope'           => 'private',
280
-                    'scope_specified' => true,
281
-                    'is_static'       => false,
282
-                ],
283
-            ],
284
-            [
285
-                '/* testGroupPrivate 7 */',
286
-                [
287
-                    'scope'           => 'private',
288
-                    'scope_specified' => true,
289
-                    'is_static'       => false,
290
-                ],
291
-            ],
292
-            [
293
-                '/* testPropertyAfterMethod */',
294
-                [
295
-                    'scope'           => 'private',
296
-                    'scope_specified' => true,
297
-                    'is_static'       => true,
298
-                ],
299
-            ],
300
-            [
301
-                '/* testInterfaceProperty */',
302
-                [],
303
-            ],
304
-            [
305
-                '/* testNestedProperty 1 */',
306
-                [
307
-                    'scope'           => 'public',
308
-                    'scope_specified' => true,
309
-                    'is_static'       => false,
310
-                ],
311
-            ],
312
-            [
313
-                '/* testNestedProperty 2 */',
314
-                [
315
-                    'scope'           => 'public',
316
-                    'scope_specified' => true,
317
-                    'is_static'       => false,
318
-                ],
319
-            ],
320
-        ];
321
-
322
-    }//end dataGetMemberProperties()
323
-
324
-
325
-    /**
326
-     * Test receiving an expected exception when a non property is passed.
327
-     *
328
-     * @param string $identifier Comment which precedes the test case.
329
-     *
330
-     * @expectedException        PHP_CodeSniffer\Exceptions\TokenizerException
331
-     * @expectedExceptionMessage $stackPtr is not a class member var
332
-     *
333
-     * @dataProvider dataNotClassProperty
334
-     *
335
-     * @return void
336
-     */
337
-    public function testNotClassPropertyException($identifier)
338
-    {
339
-        $start    = ($this->phpcsFile->numTokens - 1);
340
-        $delim    = $this->phpcsFile->findPrevious(
341
-            T_COMMENT,
342
-            $start,
343
-            null,
344
-            false,
345
-            $identifier
346
-        );
347
-        $variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
348
-
349
-        $result = $this->phpcsFile->getMemberProperties($variable);
350
-
351
-    }//end testNotClassPropertyException()
352
-
353
-
354
-    /**
355
-     * Data provider for the NotClassPropertyException test.
356
-     *
357
-     * @see testNotClassPropertyException()
358
-     *
359
-     * @return array
360
-     */
361
-    public function dataNotClassProperty()
362
-    {
363
-        return [
364
-            ['/* testMethodParam */'],
365
-            ['/* testImportedGlobal */'],
366
-            ['/* testLocalVariable */'],
367
-            ['/* testGlobalVariable */'],
368
-            ['/* testNestedMethodParam 1 */'],
369
-            ['/* testNestedMethodParam 2 */'],
370
-        ];
371
-
372
-    }//end dataNotClassProperty()
373
-
374
-
375
-    /**
376
-     * Test receiving an expected exception when a non variable is passed.
377
-     *
378
-     * @expectedException        PHP_CodeSniffer\Exceptions\TokenizerException
379
-     * @expectedExceptionMessage $stackPtr must be of type T_VARIABLE
380
-     *
381
-     * @return void
382
-     */
383
-    public function testNotAVariableException()
384
-    {
385
-        $start = ($this->phpcsFile->numTokens - 1);
386
-        $delim = $this->phpcsFile->findPrevious(
387
-            T_COMMENT,
388
-            $start,
389
-            null,
390
-            false,
391
-            '/* testNotAVariable */'
392
-        );
393
-        $next  = $this->phpcsFile->findNext(T_WHITESPACE, ($delim + 1), null, true);
394
-
395
-        $result = $this->phpcsFile->getMemberProperties($next);
396
-
397
-    }//end testNotAVariableException()
20
+	/**
21
+	 * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
+	 *
23
+	 * @var \PHP_CodeSniffer\Files\File
24
+	 */
25
+	private $phpcsFile;
26
+
27
+
28
+	/**
29
+	 * Initialize & tokenize PHP_CodeSniffer_File with code from the test case file.
30
+	 *
31
+	 * Methods used for these tests can be found in a test case file in the same
32
+	 * directory and with the same name, using the .inc extension.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function setUp()
37
+	{
38
+		$config            = new Config();
39
+		$config->standards = ['Generic'];
40
+
41
+		$ruleset = new Ruleset($config);
42
+
43
+		$pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+		$this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+		$this->phpcsFile->process();
46
+
47
+	}//end setUp()
48
+
49
+
50
+	/**
51
+	 * Clean up after finished test.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function tearDown()
56
+	{
57
+		unset($this->phpcsFile);
58
+
59
+	}//end tearDown()
60
+
61
+
62
+	/**
63
+	 * Test the getMemberProperties() method.
64
+	 *
65
+	 * @param string $identifier Comment which precedes the test case.
66
+	 * @param bool   $expected   Expected function output.
67
+	 *
68
+	 * @dataProvider dataGetMemberProperties
69
+	 *
70
+	 * @return void
71
+	 */
72
+	public function testGetMemberProperties($identifier, $expected)
73
+	{
74
+		$start    = ($this->phpcsFile->numTokens - 1);
75
+		$delim    = $this->phpcsFile->findPrevious(
76
+			T_COMMENT,
77
+			$start,
78
+			null,
79
+			false,
80
+			$identifier
81
+		);
82
+		$variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
83
+
84
+		$result = $this->phpcsFile->getMemberProperties($variable);
85
+		$this->assertSame($expected, $result);
86
+
87
+	}//end testGetMemberProperties()
88
+
89
+
90
+	/**
91
+	 * Data provider for the GetMemberProperties test.
92
+	 *
93
+	 * @see testGetMemberProperties()
94
+	 *
95
+	 * @return array
96
+	 */
97
+	public function dataGetMemberProperties()
98
+	{
99
+		return [
100
+			[
101
+				'/* testVar */',
102
+				[
103
+					'scope'           => 'public',
104
+					'scope_specified' => false,
105
+					'is_static'       => false,
106
+				],
107
+			],
108
+			[
109
+				'/* testPublic */',
110
+				[
111
+					'scope'           => 'public',
112
+					'scope_specified' => true,
113
+					'is_static'       => false,
114
+				],
115
+			],
116
+			[
117
+				'/* testProtected */',
118
+				[
119
+					'scope'           => 'protected',
120
+					'scope_specified' => true,
121
+					'is_static'       => false,
122
+				],
123
+			],
124
+			[
125
+				'/* testPrivate */',
126
+				[
127
+					'scope'           => 'private',
128
+					'scope_specified' => true,
129
+					'is_static'       => false,
130
+				],
131
+			],
132
+			[
133
+				'/* testStatic */',
134
+				[
135
+					'scope'           => 'public',
136
+					'scope_specified' => false,
137
+					'is_static'       => true,
138
+				],
139
+			],
140
+			[
141
+				'/* testStaticVar */',
142
+				[
143
+					'scope'           => 'public',
144
+					'scope_specified' => false,
145
+					'is_static'       => true,
146
+				],
147
+			],
148
+			[
149
+				'/* testVarStatic */',
150
+				[
151
+					'scope'           => 'public',
152
+					'scope_specified' => false,
153
+					'is_static'       => true,
154
+				],
155
+			],
156
+			[
157
+				'/* testPublicStatic */',
158
+				[
159
+					'scope'           => 'public',
160
+					'scope_specified' => true,
161
+					'is_static'       => true,
162
+				],
163
+			],
164
+			[
165
+				'/* testProtectedStatic */',
166
+				[
167
+					'scope'           => 'protected',
168
+					'scope_specified' => true,
169
+					'is_static'       => true,
170
+				],
171
+			],
172
+			[
173
+				'/* testPrivateStatic */',
174
+				[
175
+					'scope'           => 'private',
176
+					'scope_specified' => true,
177
+					'is_static'       => true,
178
+				],
179
+			],
180
+			[
181
+				'/* testPublicStaticWithDocblock */',
182
+				[
183
+					'scope'           => 'public',
184
+					'scope_specified' => true,
185
+					'is_static'       => true,
186
+				],
187
+			],
188
+			[
189
+				'/* testProtectedStaticWithDocblock */',
190
+				[
191
+					'scope'           => 'protected',
192
+					'scope_specified' => true,
193
+					'is_static'       => true,
194
+				],
195
+			],
196
+			[
197
+				'/* testPrivateStaticWithDocblock */',
198
+				[
199
+					'scope'           => 'private',
200
+					'scope_specified' => true,
201
+					'is_static'       => true,
202
+				],
203
+			],
204
+			[
205
+				'/* testNoPrefix */',
206
+				[
207
+					'scope'           => 'public',
208
+					'scope_specified' => false,
209
+					'is_static'       => false,
210
+				],
211
+			],
212
+			[
213
+				'/* testGroupProtectedStatic 1 */',
214
+				[
215
+					'scope'           => 'protected',
216
+					'scope_specified' => true,
217
+					'is_static'       => true,
218
+				],
219
+			],
220
+			[
221
+				'/* testGroupProtectedStatic 2 */',
222
+				[
223
+					'scope'           => 'protected',
224
+					'scope_specified' => true,
225
+					'is_static'       => true,
226
+				],
227
+			],
228
+			[
229
+				'/* testGroupProtectedStatic 3 */',
230
+				[
231
+					'scope'           => 'protected',
232
+					'scope_specified' => true,
233
+					'is_static'       => true,
234
+				],
235
+			],
236
+			[
237
+				'/* testGroupPrivate 1 */',
238
+				[
239
+					'scope'           => 'private',
240
+					'scope_specified' => true,
241
+					'is_static'       => false,
242
+				],
243
+			],
244
+			[
245
+				'/* testGroupPrivate 2 */',
246
+				[
247
+					'scope'           => 'private',
248
+					'scope_specified' => true,
249
+					'is_static'       => false,
250
+				],
251
+			],
252
+			[
253
+				'/* testGroupPrivate 3 */',
254
+				[
255
+					'scope'           => 'private',
256
+					'scope_specified' => true,
257
+					'is_static'       => false,
258
+				],
259
+			],
260
+			[
261
+				'/* testGroupPrivate 4 */',
262
+				[
263
+					'scope'           => 'private',
264
+					'scope_specified' => true,
265
+					'is_static'       => false,
266
+				],
267
+			],
268
+			[
269
+				'/* testGroupPrivate 5 */',
270
+				[
271
+					'scope'           => 'private',
272
+					'scope_specified' => true,
273
+					'is_static'       => false,
274
+				],
275
+			],
276
+			[
277
+				'/* testGroupPrivate 6 */',
278
+				[
279
+					'scope'           => 'private',
280
+					'scope_specified' => true,
281
+					'is_static'       => false,
282
+				],
283
+			],
284
+			[
285
+				'/* testGroupPrivate 7 */',
286
+				[
287
+					'scope'           => 'private',
288
+					'scope_specified' => true,
289
+					'is_static'       => false,
290
+				],
291
+			],
292
+			[
293
+				'/* testPropertyAfterMethod */',
294
+				[
295
+					'scope'           => 'private',
296
+					'scope_specified' => true,
297
+					'is_static'       => true,
298
+				],
299
+			],
300
+			[
301
+				'/* testInterfaceProperty */',
302
+				[],
303
+			],
304
+			[
305
+				'/* testNestedProperty 1 */',
306
+				[
307
+					'scope'           => 'public',
308
+					'scope_specified' => true,
309
+					'is_static'       => false,
310
+				],
311
+			],
312
+			[
313
+				'/* testNestedProperty 2 */',
314
+				[
315
+					'scope'           => 'public',
316
+					'scope_specified' => true,
317
+					'is_static'       => false,
318
+				],
319
+			],
320
+		];
321
+
322
+	}//end dataGetMemberProperties()
323
+
324
+
325
+	/**
326
+	 * Test receiving an expected exception when a non property is passed.
327
+	 *
328
+	 * @param string $identifier Comment which precedes the test case.
329
+	 *
330
+	 * @expectedException        PHP_CodeSniffer\Exceptions\TokenizerException
331
+	 * @expectedExceptionMessage $stackPtr is not a class member var
332
+	 *
333
+	 * @dataProvider dataNotClassProperty
334
+	 *
335
+	 * @return void
336
+	 */
337
+	public function testNotClassPropertyException($identifier)
338
+	{
339
+		$start    = ($this->phpcsFile->numTokens - 1);
340
+		$delim    = $this->phpcsFile->findPrevious(
341
+			T_COMMENT,
342
+			$start,
343
+			null,
344
+			false,
345
+			$identifier
346
+		);
347
+		$variable = $this->phpcsFile->findNext(T_VARIABLE, ($delim + 1));
348
+
349
+		$result = $this->phpcsFile->getMemberProperties($variable);
350
+
351
+	}//end testNotClassPropertyException()
352
+
353
+
354
+	/**
355
+	 * Data provider for the NotClassPropertyException test.
356
+	 *
357
+	 * @see testNotClassPropertyException()
358
+	 *
359
+	 * @return array
360
+	 */
361
+	public function dataNotClassProperty()
362
+	{
363
+		return [
364
+			['/* testMethodParam */'],
365
+			['/* testImportedGlobal */'],
366
+			['/* testLocalVariable */'],
367
+			['/* testGlobalVariable */'],
368
+			['/* testNestedMethodParam 1 */'],
369
+			['/* testNestedMethodParam 2 */'],
370
+		];
371
+
372
+	}//end dataNotClassProperty()
373
+
374
+
375
+	/**
376
+	 * Test receiving an expected exception when a non variable is passed.
377
+	 *
378
+	 * @expectedException        PHP_CodeSniffer\Exceptions\TokenizerException
379
+	 * @expectedExceptionMessage $stackPtr must be of type T_VARIABLE
380
+	 *
381
+	 * @return void
382
+	 */
383
+	public function testNotAVariableException()
384
+	{
385
+		$start = ($this->phpcsFile->numTokens - 1);
386
+		$delim = $this->phpcsFile->findPrevious(
387
+			T_COMMENT,
388
+			$start,
389
+			null,
390
+			false,
391
+			'/* testNotAVariable */'
392
+		);
393
+		$next  = $this->phpcsFile->findNext(T_WHITESPACE, ($delim + 1), null, true);
394
+
395
+		$result = $this->phpcsFile->getMemberProperties($next);
396
+
397
+	}//end testNotAVariableException()
398 398
 
399 399
 
400 400
 }//end class
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/tests/Core/File/FindExtendedClassNameTest.php 1 patch
Indentation   +124 added lines, -124 removed lines patch added patch discarded remove patch
@@ -17,130 +17,130 @@
 block discarded – undo
17 17
 class FindExtendedClassNameTest extends TestCase
18 18
 {
19 19
 
20
-    /**
21
-     * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
-     *
23
-     * @var \PHP_CodeSniffer\Files\File
24
-     */
25
-    private $phpcsFile;
26
-
27
-
28
-    /**
29
-     * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
-     *
31
-     * Methods used for these tests can be found in a test case file in the same
32
-     * directory and with the same name, using the .inc extension.
33
-     *
34
-     * @return void
35
-     */
36
-    public function setUp()
37
-    {
38
-        $config            = new Config();
39
-        $config->standards = ['Generic'];
40
-
41
-        $ruleset = new Ruleset($config);
42
-
43
-        $pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
-        $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
-        $this->phpcsFile->process();
46
-
47
-    }//end setUp()
48
-
49
-
50
-    /**
51
-     * Clean up after finished test.
52
-     *
53
-     * @return void
54
-     */
55
-    public function tearDown()
56
-    {
57
-        unset($this->phpcsFile);
58
-
59
-    }//end tearDown()
60
-
61
-
62
-    /**
63
-     * Test retrieving the name of the class being extended by another class
64
-     * (or interface).
65
-     *
66
-     * @param string $identifier Comment which precedes the test case.
67
-     * @param bool   $expected   Expected function output.
68
-     *
69
-     * @dataProvider dataExtendedClass
70
-     *
71
-     * @return void
72
-     */
73
-    public function testFindExtendedClassName($identifier, $expected)
74
-    {
75
-        $start   = ($this->phpcsFile->numTokens - 1);
76
-        $delim   = $this->phpcsFile->findPrevious(
77
-            T_COMMENT,
78
-            $start,
79
-            null,
80
-            false,
81
-            $identifier
82
-        );
83
-        $OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
84
-
85
-        $result = $this->phpcsFile->findExtendedClassName($OOToken);
86
-        $this->assertSame($expected, $result);
87
-
88
-    }//end testFindExtendedClassName()
89
-
90
-
91
-    /**
92
-     * Data provider for the FindExtendedClassName test.
93
-     *
94
-     * @see testFindExtendedClassName()
95
-     *
96
-     * @return array
97
-     */
98
-    public function dataExtendedClass()
99
-    {
100
-        return [
101
-            [
102
-                '/* testExtendedClass */',
103
-                'testFECNClass',
104
-            ],
105
-            [
106
-                '/* testNamespacedClass */',
107
-                '\PHP_CodeSniffer\Tests\Core\File\testFECNClass',
108
-            ],
109
-            [
110
-                '/* testNonExtendedClass */',
111
-                false,
112
-            ],
113
-            [
114
-                '/* testInterface */',
115
-                false,
116
-            ],
117
-            [
118
-                '/* testInterfaceThatExtendsInterface */',
119
-                'testFECNInterface',
120
-            ],
121
-            [
122
-                '/* testInterfaceThatExtendsFQCNInterface */',
123
-                '\PHP_CodeSniffer\Tests\Core\File\testFECNInterface',
124
-            ],
125
-            [
126
-                '/* testNestedExtendedClass */',
127
-                false,
128
-            ],
129
-            [
130
-                '/* testNestedExtendedAnonClass */',
131
-                'testFECNAnonClass',
132
-            ],
133
-            [
134
-                '/* testClassThatExtendsAndImplements */',
135
-                'testFECNClass',
136
-            ],
137
-            [
138
-                '/* testClassThatImplementsAndExtends */',
139
-                'testFECNClass',
140
-            ],
141
-        ];
142
-
143
-    }//end dataExtendedClass()
20
+	/**
21
+	 * The PHP_CodeSniffer_File object containing parsed contents of the test case file.
22
+	 *
23
+	 * @var \PHP_CodeSniffer\Files\File
24
+	 */
25
+	private $phpcsFile;
26
+
27
+
28
+	/**
29
+	 * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
+	 *
31
+	 * Methods used for these tests can be found in a test case file in the same
32
+	 * directory and with the same name, using the .inc extension.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function setUp()
37
+	{
38
+		$config            = new Config();
39
+		$config->standards = ['Generic'];
40
+
41
+		$ruleset = new Ruleset($config);
42
+
43
+		$pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+		$this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+		$this->phpcsFile->process();
46
+
47
+	}//end setUp()
48
+
49
+
50
+	/**
51
+	 * Clean up after finished test.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function tearDown()
56
+	{
57
+		unset($this->phpcsFile);
58
+
59
+	}//end tearDown()
60
+
61
+
62
+	/**
63
+	 * Test retrieving the name of the class being extended by another class
64
+	 * (or interface).
65
+	 *
66
+	 * @param string $identifier Comment which precedes the test case.
67
+	 * @param bool   $expected   Expected function output.
68
+	 *
69
+	 * @dataProvider dataExtendedClass
70
+	 *
71
+	 * @return void
72
+	 */
73
+	public function testFindExtendedClassName($identifier, $expected)
74
+	{
75
+		$start   = ($this->phpcsFile->numTokens - 1);
76
+		$delim   = $this->phpcsFile->findPrevious(
77
+			T_COMMENT,
78
+			$start,
79
+			null,
80
+			false,
81
+			$identifier
82
+		);
83
+		$OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
84
+
85
+		$result = $this->phpcsFile->findExtendedClassName($OOToken);
86
+		$this->assertSame($expected, $result);
87
+
88
+	}//end testFindExtendedClassName()
89
+
90
+
91
+	/**
92
+	 * Data provider for the FindExtendedClassName test.
93
+	 *
94
+	 * @see testFindExtendedClassName()
95
+	 *
96
+	 * @return array
97
+	 */
98
+	public function dataExtendedClass()
99
+	{
100
+		return [
101
+			[
102
+				'/* testExtendedClass */',
103
+				'testFECNClass',
104
+			],
105
+			[
106
+				'/* testNamespacedClass */',
107
+				'\PHP_CodeSniffer\Tests\Core\File\testFECNClass',
108
+			],
109
+			[
110
+				'/* testNonExtendedClass */',
111
+				false,
112
+			],
113
+			[
114
+				'/* testInterface */',
115
+				false,
116
+			],
117
+			[
118
+				'/* testInterfaceThatExtendsInterface */',
119
+				'testFECNInterface',
120
+			],
121
+			[
122
+				'/* testInterfaceThatExtendsFQCNInterface */',
123
+				'\PHP_CodeSniffer\Tests\Core\File\testFECNInterface',
124
+			],
125
+			[
126
+				'/* testNestedExtendedClass */',
127
+				false,
128
+			],
129
+			[
130
+				'/* testNestedExtendedAnonClass */',
131
+				'testFECNAnonClass',
132
+			],
133
+			[
134
+				'/* testClassThatExtendsAndImplements */',
135
+				'testFECNClass',
136
+			],
137
+			[
138
+				'/* testClassThatImplementsAndExtends */',
139
+				'testFECNClass',
140
+			],
141
+		];
142
+
143
+	}//end dataExtendedClass()
144 144
 
145 145
 
146 146
 }//end class
Please login to merge, or discard this patch.
php_codesniffer/tests/Core/File/FindImplementedInterfaceNamesTest.php 1 patch
Indentation   +120 added lines, -120 removed lines patch added patch discarded remove patch
@@ -17,126 +17,126 @@
 block discarded – undo
17 17
 class FindImplementedInterfaceNamesTest extends TestCase
18 18
 {
19 19
 
20
-    /**
21
-     * The \PHP_CodeSniffer\Files\File object containing parsed contents of the test case file.
22
-     *
23
-     * @var \PHP_CodeSniffer\Files\File
24
-     */
25
-    private $phpcsFile;
26
-
27
-
28
-    /**
29
-     * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
-     *
31
-     * Methods used for these tests can be found in a test case file in the same
32
-     * directory and with the same name, using the .inc extension.
33
-     *
34
-     * @return void
35
-     */
36
-    public function setUp()
37
-    {
38
-        $config            = new Config();
39
-        $config->standards = ['Generic'];
40
-
41
-        $ruleset = new Ruleset($config);
42
-
43
-        $pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
-        $this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
-        $this->phpcsFile->process();
46
-
47
-    }//end setUp()
48
-
49
-
50
-    /**
51
-     * Clean up after finished test.
52
-     *
53
-     * @return void
54
-     */
55
-    public function tearDown()
56
-    {
57
-        unset($this->phpcsFile);
58
-
59
-    }//end tearDown()
60
-
61
-
62
-    /**
63
-     * Test retrieving the name(s) of the interfaces being implemented by a class.
64
-     *
65
-     * @param string $identifier Comment which precedes the test case.
66
-     * @param bool   $expected   Expected function output.
67
-     *
68
-     * @dataProvider dataImplementedInterface
69
-     *
70
-     * @return void
71
-     */
72
-    public function testFindImplementedInterfaceNames($identifier, $expected)
73
-    {
74
-        $start   = ($this->phpcsFile->numTokens - 1);
75
-        $delim   = $this->phpcsFile->findPrevious(
76
-            T_COMMENT,
77
-            $start,
78
-            null,
79
-            false,
80
-            $identifier
81
-        );
82
-        $OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
83
-
84
-        $result = $this->phpcsFile->findImplementedInterfaceNames($OOToken);
85
-        $this->assertSame($expected, $result);
86
-
87
-    }//end testFindImplementedInterfaceNames()
88
-
89
-
90
-    /**
91
-     * Data provider for the FindImplementedInterfaceNames test.
92
-     *
93
-     * @see testFindImplementedInterfaceNames()
94
-     *
95
-     * @return array
96
-     */
97
-    public function dataImplementedInterface()
98
-    {
99
-        return [
100
-            [
101
-                '/* testImplementedClass */',
102
-                ['testFIINInterface'],
103
-            ],
104
-            [
105
-                '/* testMultiImplementedClass */',
106
-                [
107
-                    'testFIINInterface',
108
-                    'testFIINInterface2',
109
-                ],
110
-            ],
111
-            [
112
-                '/* testNamespacedClass */',
113
-                ['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'],
114
-            ],
115
-            [
116
-                '/* testNonImplementedClass */',
117
-                false,
118
-            ],
119
-            [
120
-                '/* testInterface */',
121
-                false,
122
-            ],
123
-            [
124
-                '/* testClassThatExtendsAndImplements */',
125
-                [
126
-                    'InterfaceA',
127
-                    '\NameSpaced\Cat\InterfaceB',
128
-                ],
129
-            ],
130
-            [
131
-                '/* testClassThatImplementsAndExtends */',
132
-                [
133
-                    '\InterfaceA',
134
-                    'InterfaceB',
135
-                ],
136
-            ],
137
-        ];
138
-
139
-    }//end dataImplementedInterface()
20
+	/**
21
+	 * The \PHP_CodeSniffer\Files\File object containing parsed contents of the test case file.
22
+	 *
23
+	 * @var \PHP_CodeSniffer\Files\File
24
+	 */
25
+	private $phpcsFile;
26
+
27
+
28
+	/**
29
+	 * Initialize & tokenize \PHP_CodeSniffer\Files\File with code from the test case file.
30
+	 *
31
+	 * Methods used for these tests can be found in a test case file in the same
32
+	 * directory and with the same name, using the .inc extension.
33
+	 *
34
+	 * @return void
35
+	 */
36
+	public function setUp()
37
+	{
38
+		$config            = new Config();
39
+		$config->standards = ['Generic'];
40
+
41
+		$ruleset = new Ruleset($config);
42
+
43
+		$pathToTestFile  = dirname(__FILE__).'/'.basename(__FILE__, '.php').'.inc';
44
+		$this->phpcsFile = new DummyFile(file_get_contents($pathToTestFile), $ruleset, $config);
45
+		$this->phpcsFile->process();
46
+
47
+	}//end setUp()
48
+
49
+
50
+	/**
51
+	 * Clean up after finished test.
52
+	 *
53
+	 * @return void
54
+	 */
55
+	public function tearDown()
56
+	{
57
+		unset($this->phpcsFile);
58
+
59
+	}//end tearDown()
60
+
61
+
62
+	/**
63
+	 * Test retrieving the name(s) of the interfaces being implemented by a class.
64
+	 *
65
+	 * @param string $identifier Comment which precedes the test case.
66
+	 * @param bool   $expected   Expected function output.
67
+	 *
68
+	 * @dataProvider dataImplementedInterface
69
+	 *
70
+	 * @return void
71
+	 */
72
+	public function testFindImplementedInterfaceNames($identifier, $expected)
73
+	{
74
+		$start   = ($this->phpcsFile->numTokens - 1);
75
+		$delim   = $this->phpcsFile->findPrevious(
76
+			T_COMMENT,
77
+			$start,
78
+			null,
79
+			false,
80
+			$identifier
81
+		);
82
+		$OOToken = $this->phpcsFile->findNext([T_CLASS, T_ANON_CLASS, T_INTERFACE], ($delim + 1));
83
+
84
+		$result = $this->phpcsFile->findImplementedInterfaceNames($OOToken);
85
+		$this->assertSame($expected, $result);
86
+
87
+	}//end testFindImplementedInterfaceNames()
88
+
89
+
90
+	/**
91
+	 * Data provider for the FindImplementedInterfaceNames test.
92
+	 *
93
+	 * @see testFindImplementedInterfaceNames()
94
+	 *
95
+	 * @return array
96
+	 */
97
+	public function dataImplementedInterface()
98
+	{
99
+		return [
100
+			[
101
+				'/* testImplementedClass */',
102
+				['testFIINInterface'],
103
+			],
104
+			[
105
+				'/* testMultiImplementedClass */',
106
+				[
107
+					'testFIINInterface',
108
+					'testFIINInterface2',
109
+				],
110
+			],
111
+			[
112
+				'/* testNamespacedClass */',
113
+				['\PHP_CodeSniffer\Tests\Core\File\testFIINInterface'],
114
+			],
115
+			[
116
+				'/* testNonImplementedClass */',
117
+				false,
118
+			],
119
+			[
120
+				'/* testInterface */',
121
+				false,
122
+			],
123
+			[
124
+				'/* testClassThatExtendsAndImplements */',
125
+				[
126
+					'InterfaceA',
127
+					'\NameSpaced\Cat\InterfaceB',
128
+				],
129
+			],
130
+			[
131
+				'/* testClassThatImplementsAndExtends */',
132
+				[
133
+					'\InterfaceA',
134
+					'InterfaceB',
135
+				],
136
+			],
137
+		];
138
+
139
+	}//end dataImplementedInterface()
140 140
 
141 141
 
142 142
 }//end class
Please login to merge, or discard this patch.
squizlabs/php_codesniffer/tests/Core/File/GetMethodPropertiesTest.inc 1 patch
Indentation   +31 added lines, -31 removed lines patch added patch discarded remove patch
@@ -6,56 +6,56 @@
 block discarded – undo
6 6
 /* testReturnFunction */
7 7
 function myFunction(array ...$arrays): array
8 8
 {
9
-    return array_map(/* testNestedClosure */function(array $array): int {
10
-        return array_sum($array);
11
-    }, $arrays);
9
+	return array_map(/* testNestedClosure */function(array $array): int {
10
+		return array_sum($array);
11
+	}, $arrays);
12 12
 }
13 13
 
14 14
 class MyClass {
15
-    /* testBasicMethod */
16
-    function myFunction() {}
15
+	/* testBasicMethod */
16
+	function myFunction() {}
17 17
 
18
-    /* testPrivateStaticMethod */
19
-    private static function myFunction() {}
18
+	/* testPrivateStaticMethod */
19
+	private static function myFunction() {}
20 20
 
21
-    /* testFinalMethod */
22
-    final public function myFunction() {}
21
+	/* testFinalMethod */
22
+	final public function myFunction() {}
23 23
 
24
-    /* testProtectedReturnMethod */
25
-    protected function myFunction() : int {}
24
+	/* testProtectedReturnMethod */
25
+	protected function myFunction() : int {}
26 26
 
27
-    /* testPublicReturnMethod */
28
-    public function myFunction(): array {}
27
+	/* testPublicReturnMethod */
28
+	public function myFunction(): array {}
29 29
 
30
-    /* testNullableReturnMethod */
31
-    public function myFunction(): ?array {}
30
+	/* testNullableReturnMethod */
31
+	public function myFunction(): ?array {}
32 32
 
33
-    /* testMessyNullableReturnMethod */
34
-    public function myFunction() /* comment
33
+	/* testMessyNullableReturnMethod */
34
+	public function myFunction() /* comment
35 35
         */ :  
36
-        /* comment */ ? //comment
37
-        array {}
36
+		/* comment */ ? //comment
37
+		array {}
38 38
 
39
-    /* testReturnNamespace */
40
-    function myFunction(): \MyNamespace\MyClass {}
39
+	/* testReturnNamespace */
40
+	function myFunction(): \MyNamespace\MyClass {}
41 41
 
42
-    /* testReturnMultilineNamespace */
43
-    function myFunction(): \MyNamespace /** comment *\/ comment */
44
-                           \MyClass /* comment */
45
-                           \Foo {}
42
+	/* testReturnMultilineNamespace */
43
+	function myFunction(): \MyNamespace /** comment *\/ comment */
44
+						   \MyClass /* comment */
45
+						   \Foo {}
46 46
 }
47 47
 
48 48
 abstract class MyClass
49 49
 {
50
-    /* testAbstractMethod */
51
-    abstract function myFunction();
50
+	/* testAbstractMethod */
51
+	abstract function myFunction();
52 52
 
53
-    /* testAbstractReturnMethod */
54
-    abstract protected function myFunction(): bool;
53
+	/* testAbstractReturnMethod */
54
+	abstract protected function myFunction(): bool;
55 55
 }
56 56
 
57 57
 interface MyInterface
58 58
 {
59
-    /* testInterfaceMethod */
60
-    function myFunction();
59
+	/* testInterfaceMethod */
60
+	function myFunction();
61 61
 }
Please login to merge, or discard this patch.