codechecker.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * Copyright (c) 2015 Thomas Müller <deepdiver@owncloud.com>
  4. * This file is licensed under the Affero General Public License version 3 or
  5. * later.
  6. * See the COPYING-README file.
  7. */
  8. namespace Test\App;
  9. use OC;
  10. class CodeChecker extends \Test\TestCase {
  11. /**
  12. * @dataProvider providesFilesToCheck
  13. * @param $expectedErrors
  14. * @param $fileToVerify
  15. */
  16. public function testFindInvalidUsage($expectedErrorToken, $expectedErrorCode, $fileToVerify) {
  17. $checker = new OC\App\CodeChecker();
  18. $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify");
  19. $this->assertEquals(1, count($errors));
  20. $this->assertEquals($expectedErrorCode, $errors[0]['errorCode']);
  21. $this->assertEquals($expectedErrorToken, $errors[0]['disallowedToken']);
  22. }
  23. public function providesFilesToCheck() {
  24. return [
  25. ['OC_Hook', 1000, 'test-extends.php'],
  26. ['oC_Avatar', 1001, 'test-implements.php'],
  27. ['OC_App', 1002, 'test-static-call.php'],
  28. ['OC_API', 1003, 'test-const.php'],
  29. ['OC_AppConfig', 1004, 'test-new.php'],
  30. ];
  31. }
  32. }