diff options
author | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-07 12:08:12 +0200 |
---|---|---|
committer | Joas Schilling <nickvergessen@owncloud.com> | 2015-07-17 12:34:56 +0200 |
commit | bba87a2a3b46d20a552efa4a1d00d3253aedf27b (patch) | |
tree | b243d9e54018e114123b53021d0d93c327fbefcc /tests | |
parent | 9e469046faee66171be15fa6d0bb6eef2289fa0f (diff) | |
download | nextcloud-server-bba87a2a3b46d20a552efa4a1d00d3253aedf27b.tar.gz nextcloud-server-bba87a2a3b46d20a552efa4a1d00d3253aedf27b.zip |
Restructor the code into different classes instead of extending
Diffstat (limited to 'tests')
-rw-r--r-- | tests/lib/app/codechecker/codecheckertest.php (renamed from tests/lib/app/codechecker.php) | 12 | ||||
-rw-r--r-- | tests/lib/app/codechecker/deprecationlisttest.php (renamed from tests/lib/app/deprecationcodechecker.php) | 10 | ||||
-rw-r--r-- | tests/lib/app/codechecker/mock/testlist.php | 81 | ||||
-rw-r--r-- | tests/lib/app/codechecker/nodevisitortest.php (renamed from tests/lib/app/codecheckvisitor.php) | 8 | ||||
-rw-r--r-- | tests/lib/app/mock/codechecker.php | 49 |
5 files changed, 101 insertions, 59 deletions
diff --git a/tests/lib/app/codechecker.php b/tests/lib/app/codechecker/codecheckertest.php index 435aedfe3ad..93bf0b32c58 100644 --- a/tests/lib/app/codechecker.php +++ b/tests/lib/app/codechecker/codecheckertest.php @@ -6,12 +6,12 @@ * See the COPYING-README file. */ -namespace Test\App; +namespace Test\App\CodeChecker; use OC; use Test\TestCase; -class CodeChecker extends TestCase { +class CodeCheckerTest extends TestCase { /** * @dataProvider providesFilesToCheck @@ -20,7 +20,9 @@ class CodeChecker extends TestCase { * @param string $fileToVerify */ public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) { - $checker = new OC\App\CodeChecker(); + $checker = new OC\App\CodeChecker\CodeChecker( + new OC\App\CodeChecker\PrivateList() + ); $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); $this->assertEquals(1, count($errors)); @@ -44,7 +46,9 @@ class CodeChecker extends TestCase { * @param string $fileToVerify */ public function testPassValidUsage($fileToVerify) { - $checker = new OC\App\CodeChecker(); + $checker = new OC\App\CodeChecker\CodeChecker( + new OC\App\CodeChecker\PrivateList() + ); $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); $this->assertEquals(0, count($errors)); diff --git a/tests/lib/app/deprecationcodechecker.php b/tests/lib/app/codechecker/deprecationlisttest.php index 57d9ca85a7a..2293d31a1f6 100644 --- a/tests/lib/app/deprecationcodechecker.php +++ b/tests/lib/app/codechecker/deprecationlisttest.php @@ -11,7 +11,7 @@ namespace Test\App; use OC; use Test\TestCase; -class DeprecationCodeChecker extends TestCase { +class DeprecationListTest extends TestCase { /** * @dataProvider providesFilesToCheck @@ -20,7 +20,9 @@ class DeprecationCodeChecker extends TestCase { * @param string $fileToVerify */ public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) { - $checker = new \OC\App\DeprecationCodeChecker(); + $checker = new OC\App\CodeChecker\CodeChecker( + new OC\App\CodeChecker\DeprecationList() + ); $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); $this->assertEquals(1, count($errors)); @@ -44,7 +46,9 @@ class DeprecationCodeChecker extends TestCase { * @param string $fileToVerify */ public function testPassValidUsage($fileToVerify) { - $checker = new \OC\App\DeprecationCodeChecker(); + $checker = new OC\App\CodeChecker\CodeChecker( + new OC\App\CodeChecker\DeprecationList() + ); $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); $this->assertEquals(0, count($errors)); diff --git a/tests/lib/app/codechecker/mock/testlist.php b/tests/lib/app/codechecker/mock/testlist.php new file mode 100644 index 00000000000..c4985e8e625 --- /dev/null +++ b/tests/lib/app/codechecker/mock/testlist.php @@ -0,0 +1,81 @@ +<?php +/** + * @author Joas Schilling <nickvergessen@owncloud.com> + * + * @copyright Copyright (c) 2015, ownCloud, Inc. + * @license AGPL-3.0 + * + * This code is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License, version 3, + * as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License, version 3, + * along with this program. If not, see <http://www.gnu.org/licenses/> + * + */ + +namespace Test\App\CodeChecker\Mock; + +use OC\App\CodeChecker\ICheckList; + +class TestList implements ICheckList { + + /** + * @return string + */ + public function getDescription() { + return 'deprecated'; + } + + /** + * @return array E.g.: `'ClassName' => 'oc version',` + */ + public function getClasses() { + return [ + // Deprecated classes + 'OCP\AppFramework\IApi' => '8.0.0', + ]; + } + + /** + * @return array E.g.: `'ClassName::CONSTANT_NAME' => 'oc version',` + */ + public function getConstants() { + return [ + // Deprecated constants + 'OCP\NamespaceName\ClassName::CONSTANT_NAME' => '8.0.0', + ]; + } + + /** + * @return array E.g.: `'functionName' => 'oc version',` + */ + public function getFunctions() { + return [ + // Deprecated functions + 'OCP\NamespaceName\ClassName::functionName' => '8.0.0', + ]; + } + + /** + * @return array E.g.: `'ClassName::methodName' => 'oc version',` + */ + public function getMethods() { + return [ + // Deprecated methods + 'OCP\NamespaceName\ClassName::methodName' => '8.0.0', + ]; + } + + /** + * @return bool + */ + public function checkStrongComparisons() { + return true; + } +} diff --git a/tests/lib/app/codecheckvisitor.php b/tests/lib/app/codechecker/nodevisitortest.php index d836f1b3c84..1207ca6a043 100644 --- a/tests/lib/app/codecheckvisitor.php +++ b/tests/lib/app/codechecker/nodevisitortest.php @@ -6,12 +6,12 @@ * See the COPYING-README file. */ -namespace Test\App; +namespace Test\AppCodeChecker; use OC; use Test\TestCase; -class CodeCheckVisitor extends TestCase { +class NodeVisitorTest extends TestCase { public function providesFilesToCheck() { return [ @@ -56,7 +56,9 @@ class CodeCheckVisitor extends TestCase { * @param string $fileToVerify */ public function testMethodsToCheck($expectedErrors, $fileToVerify) { - $checker = new \Test\App\Mock\CodeChecker(); + $checker = new OC\App\CodeChecker\CodeChecker( + new \Test\App\CodeChecker\Mock\TestList() + ); $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify"); $this->assertCount(sizeof($expectedErrors), $errors); diff --git a/tests/lib/app/mock/codechecker.php b/tests/lib/app/mock/codechecker.php deleted file mode 100644 index b5a775cc43d..00000000000 --- a/tests/lib/app/mock/codechecker.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * @author Joas Schilling <nickvergessen@owncloud.com> - * - * @copyright Copyright (c) 2015, ownCloud, Inc. - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see <http://www.gnu.org/licenses/> - * - */ - -namespace Test\App\Mock; - -class CodeChecker extends \OC\App\CodeChecker { - protected $checkEqualOperators = true; - - /** @var string */ - protected $blackListDescription = 'deprecated'; - - protected $blackListedClassNames = [ - // Deprecated classes - 'OCP\AppFramework\IApi' => '8.0.0', - ]; - - protected $blackListedConstants = [ - // Deprecated constants - 'OCP\NamespaceName\ClassName::CONSTANT_NAME' => '8.0.0', - ]; - - protected $blackListedFunctions = [ - // Deprecated functions - 'OCP\NamespaceName\ClassName::functionName' => '8.0.0', - ]; - - protected $blackListedMethods = [ - // Deprecated methods - 'OCP\NamespaceName\ClassName::methodName' => '8.0.0', - ]; -} |