diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-15 17:50:37 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-17 12:34:56 +0200 |
commit | 2783a780708e4e5c04b6935840416d219bc4d852 (patch) | |
tree | 1e2ff2fa51e2e9eeb8ae72bcf68718ba720cac07 /tests/lib/app | |
parent | f228a3dc28b579b3d11126544928edacd2e2d9c4 (diff) | |
download | nextcloud-server-2783a780708e4e5c04b6935840416d219bc4d852.tar.gz nextcloud-server-2783a780708e4e5c04b6935840416d219bc4d852.zip |
Allow checking for functions
Diffstat (limited to 'tests/lib/app')
-rw-r--r-- | tests/lib/app/codecheckvisitor.php | 28 | ||||
-rw-r--r-- | tests/lib/app/mock/codechecker.php | 5 |
2 files changed, 31 insertions, 2 deletions
diff --git a/tests/lib/app/codecheckvisitor.php b/tests/lib/app/codecheckvisitor.php index 4b663cf40b7..3eac3beedc8 100644 --- a/tests/lib/app/codecheckvisitor.php +++ b/tests/lib/app/codecheckvisitor.php @@ -40,9 +40,9 @@ class CodeCheckVisitor extends TestCase { public function providesConstantsToCheck() { return [ ['OCP\NamespaceName\ClassName::CONSTANT_NAME', 1003, 'test-deprecated-constant.php'], - ['Constant::CONSTANT_NAME', 1003, 'test-deprecated-constant-alias.php'], + ['Alias::CONSTANT_NAME', 1003, 'test-deprecated-constant-alias.php'], ['NamespaceName\ClassName::CONSTANT_NAME', 1003, 'test-deprecated-constant-sub.php'], - ['Constant\ClassName::CONSTANT_NAME', 1003, 'test-deprecated-constant-sub-alias.php'], + ['SubAlias\ClassName::CONSTANT_NAME', 1003, 'test-deprecated-constant-sub-alias.php'], ]; } @@ -60,4 +60,28 @@ class CodeCheckVisitor extends TestCase { $this->assertEquals($expectedErrorCode, $errors[0]['errorCode']); $this->assertEquals($expectedErrorToken, $errors[0]['disallowedToken']); } + + public function providesFunctionsToCheck() { + return [ + ['OCP\NamespaceName\ClassName::functionName', 1002, 'test-deprecated-function.php'], + ['Alias::functionName', 1002, 'test-deprecated-function-alias.php'], + ['NamespaceName\ClassName::functionName', 1002, 'test-deprecated-function-sub.php'], + ['SubAlias\ClassName::functionName', 1002, 'test-deprecated-function-sub-alias.php'], + ]; + } + + /** + * @dataProvider providesFunctionsToCheck + * @param string $expectedErrorToken + * @param int $expectedErrorCode + * @param string $fileToVerify + */ + public function testFunctionsToCheck($expectedErrorToken, $expectedErrorCode, $fileToVerify) { + $checker = new \Test\App\Mock\CodeChecker(); + $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); + + $this->assertEquals(1, count($errors)); + $this->assertEquals($expectedErrorCode, $errors[0]['errorCode']); + $this->assertEquals($expectedErrorToken, $errors[0]['disallowedToken']); + } } diff --git a/tests/lib/app/mock/codechecker.php b/tests/lib/app/mock/codechecker.php index 228fd881e44..e67d060b1f4 100644 --- a/tests/lib/app/mock/codechecker.php +++ b/tests/lib/app/mock/codechecker.php @@ -36,4 +36,9 @@ class CodeChecker extends \OC\App\CodeChecker { // Deprecated constants 'OCP\NamespaceName\ClassName::CONSTANT_NAME' => '8.0.0', ]; + + protected $blackListedFunctions = [ + // Deprecated constants + 'OCP\NamespaceName\ClassName::functionName' => '8.0.0', + ]; } |