diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-06-15 12:51:22 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-17 12:34:55 +0200 |
commit | 4e95031ec4e74bb99dc2dc819ddb77893564e01c (patch) | |
tree | 1ba2dc23561b21afa4164985754b36e69859fb96 /tests | |
parent | 3fae984b561e59db62e5ad15d7da417ed957ef8d (diff) | |
download | nextcloud-server-4e95031ec4e74bb99dc2dc819ddb77893564e01c.tar.gz nextcloud-server-4e95031ec4e74bb99dc2dc819ddb77893564e01c.zip |
Allow app:check-code to check for deprecated methods
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/app/codechecker.php | 2 | ||||
-rw-r--r-- | tests/lib/app/deprecationcodechecker.php | 59 |
2 files changed, 59 insertions, 2 deletions
diff --git a/tests/lib/app/codechecker.php b/tests/lib/app/codechecker.php index f45ee02d185..36c1251b8c5 100644 --- a/tests/lib/app/codechecker.php +++ b/tests/lib/app/codechecker.php @@ -35,8 +35,6 @@ class CodeChecker extends TestCase { ['OC_App', 1002, 'test-static-call.php'], ['OC_API', 1003, 'test-const.php'], ['OC_AppConfig', 1004, 'test-new.php'], - ['==', 1005, 'test-equal.php'], - ['!=', 1005, 'test-not-equal.php'], ]; } diff --git a/tests/lib/app/deprecationcodechecker.php b/tests/lib/app/deprecationcodechecker.php new file mode 100644 index 00000000000..3f3baa7c314 --- /dev/null +++ b/tests/lib/app/deprecationcodechecker.php @@ -0,0 +1,59 @@ +<?php +/** + * Copyright (c) 2015 Joas Schilling <nickvergessen@owncloud.com> + * This file is licensed under the Affero General Public License version 3 or + * later. + * See the COPYING-README file. + */ + +namespace Test\App; + +use OC; +use Test\TestCase; + +class DeprecationCodeChecker extends TestCase { + + /** + * @dataProvider providesFilesToCheck + * @param $expectedErrorToken + * @param $expectedErrorCode + * @param $fileToVerify + */ + public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) { + $checker = new \OC\App\DeprecationCodeChecker(); + $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']); + } + + public function providesFilesToCheck() { + return [ + ['==', 1005, 'test-equal.php'], + ['!=', 1005, 'test-not-equal.php'], + ]; + } + + /** + * @dataProvider validFilesData + * @param $fileToVerify + */ + public function testPassValidUsage($fileToVerify) { + $checker = new \OC\App\DeprecationCodeChecker(); + $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); + + $this->assertEquals(0, count($errors)); + } + + public function validFilesData() { + return [ + ['test-extends.php'], + ['test-implements.php'], + ['test-static-call.php'], + ['test-const.php'], + ['test-new.php'], + ['test-identical-operator.php'], + ]; + } +} |