-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify that sub namespaces in test match the expected location
Added one more check to the unit tests naming sniff that now verify, for testcase clases, that they are in the expected subdirectory, following the general namespace rules for stuff under the "classes" directory. Note that we still aren't checking the correctness under "classes" and, once that's implemented, surely some code here will be moved to the general namespaces sniff (a note about that has been added to code). Also, note that we aren't still checking for level2 correctness, that must be a valid API or "local", whenever that's possible it will be checked. So, this only validates that the location (sub-directories) of the file matches the sub-namespaces of the class. Covered with tests.
- Loading branch information
Showing
5 changed files
with
62 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
moodle/tests/fixtures/phpunit/testcasenames_correct_level2ns.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace local_codechecker\fixtures\phpunit; // Not correct level2, but we aren't checking that. Just correct location. | ||
defined("MOODLE_INTERNAL") || die(); // Make this always the 1st line in all CS fixtures. | ||
|
||
/** | ||
* Correct class, using correct location matching sub-namespaces. | ||
*/ | ||
class testcasenames_correct_level2ns extends local_codechecker_testcase { | ||
public function test_something() { | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
moodle/tests/fixtures/phpunit/testcasenames_unexpected_level2ns.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
namespace local_codechecker\level2\level3; | ||
defined("MOODLE_INTERNAL") || die(); // Make this always the 1st line in all CS fixtures. | ||
|
||
/** | ||
* Correct class, just the namespace level2 and level3 don't correspond with the expected location. | ||
*/ | ||
class testcasenames_unexpected_level2ns extends local_codechecker_testcase { | ||
public function test_something() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters