-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #326 from kabalin/filter-req
Adjust filter plugin validation requirements to comply with Moodle 4.5
- Loading branch information
Showing
13 changed files
with
290 additions
and
13 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Moodle Plugin CI package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Copyright (c) 2024 Moodle Pty Ltd <[email protected]> | ||
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace MoodlePluginCI\PluginValidate\Finder; | ||
|
||
use PhpParser\Node\Name; | ||
|
||
/** | ||
* Finds function call. | ||
*/ | ||
class FunctionCallFinder extends AbstractParserFinder | ||
{ | ||
public function getType(): string | ||
{ | ||
return 'function call'; | ||
} | ||
|
||
public function findTokens($file, FileTokens $fileTokens): void | ||
{ | ||
$statements = $this->parser->parseFile($file); | ||
|
||
foreach ($this->filter->filterFunctionCalls($statements) as $funccall) { | ||
if ($funccall->name instanceof Name) { | ||
$fileTokens->compare((string) $funccall->name); | ||
} | ||
} | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Moodle Plugin CI package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Copyright (c) 2024 Moodle Pty Ltd <[email protected]> | ||
* License http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later | ||
*/ | ||
|
||
namespace MoodlePluginCI\Tests\PluginValidate\Finder; | ||
|
||
use MoodlePluginCI\PluginValidate\Finder\FileTokens; | ||
use MoodlePluginCI\PluginValidate\Finder\FunctionCallFinder; | ||
|
||
class FunctionCallFinderTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
public function testFindTokens() | ||
{ | ||
$file = __DIR__ . '/../../Fixture/moodle-local_ci/lib.php'; | ||
$fileTokens = FileTokens::create('lib.php')->mustHave('local_ci_subtract'); | ||
|
||
$finder = new FunctionCallFinder(); | ||
$finder->findTokens($file, $fileTokens); | ||
|
||
$this->assertTrue($fileTokens->hasFoundAllTokens()); | ||
$this->assertFalse($fileTokens->hasHint()); | ||
} | ||
|
||
public function testFindTokensNotFound() | ||
{ | ||
$file = __DIR__ . '/../../Fixture/moodle-local_ci/lib.php'; | ||
$fileTokens = FileTokens::create('lib.php')->mustHave('exit')->notFoundHint('Exit not found'); | ||
|
||
$finder = new FunctionCallFinder(); | ||
$finder->findTokens($file, $fileTokens); | ||
|
||
$this->assertFalse($fileTokens->hasFoundAllTokens()); | ||
$this->assertTrue($fileTokens->hasHint()); | ||
$this->assertSame('Exit not found', $fileTokens->hint); | ||
} | ||
} |
Oops, something went wrong.