summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2015-05-05 13:09:12 +0200
committerMorris Jobke <hey@morrisjobke.de>2015-05-05 13:09:12 +0200
commit493844eda4ec955b0d12e5c84412b42ae1df3fe2 (patch)
treef48593e10d97742bc28b28dfc2485a2443a86dfa
parentaae098c24a2c588ff195427f3404b9d679fd9eba (diff)
downloadnextcloud-server-493844eda4ec955b0d12e5c84412b42ae1df3fe2.tar.gz
nextcloud-server-493844eda4ec955b0d12e5c84412b42ae1df3fe2.zip
add positive tests for operator in code checker
-rw-r--r--tests/data/app/code-checker/test-identical-operator.php13
-rw-r--r--tests/lib/app/codechecker.php17
2 files changed, 30 insertions, 0 deletions
diff --git a/tests/data/app/code-checker/test-identical-operator.php b/tests/data/app/code-checker/test-identical-operator.php
new file mode 100644
index 00000000000..4c7641ede89
--- /dev/null
+++ b/tests/data/app/code-checker/test-identical-operator.php
@@ -0,0 +1,13 @@
+<?php
+
+/**
+ * Class GoodClass - uses identical operator
+ */
+class GoodClass {
+ public function foo() {
+ if (true === false) {
+ }
+ if (true !== false) {
+ }
+ }
+}
diff --git a/tests/lib/app/codechecker.php b/tests/lib/app/codechecker.php
index 5f4fe162c1d..f45ee02d185 100644
--- a/tests/lib/app/codechecker.php
+++ b/tests/lib/app/codechecker.php
@@ -39,4 +39,21 @@ class CodeChecker extends TestCase {
['!=', 1005, 'test-not-equal.php'],
];
}
+
+ /**
+ * @dataProvider validFilesData
+ * @param $fileToVerify
+ */
+ public function testPassValidUsage($fileToVerify) {
+ $checker = new OC\App\CodeChecker();
+ $errors = $checker->analyseFile(OC::$SERVERROOT . "/tests/data/app/code-checker/$fileToVerify");
+
+ $this->assertEquals(0, count($errors));
+ }
+
+ public function validFilesData() {
+ return [
+ ['test-identical-operator.php'],
+ ];
+ }
}