Skip to content

Commit

Permalink
code review
Browse files Browse the repository at this point in the history
  • Loading branch information
rdebleu committed Oct 23, 2023
1 parent 30cefb1 commit a1c9264
Show file tree
Hide file tree
Showing 18 changed files with 70 additions and 25 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,6 @@ jobs:

- name: coveralls
if: ${{ !cancelled() }}
run: moodle-plugin-ci coveralls-upload
run: moodle-plugin-ci coveralls-upload || true
env:
COVERALLS_REPO_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 0 additions & 1 deletion classes/event/report_viewed.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class report_viewed extends \core\event\base {

/**
* Init method.
*
Expand Down
3 changes: 1 addition & 2 deletions classes/privacy/provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,13 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class provider implements \core_privacy\local\metadata\null_provider {

/**
* Get the language string identifier with the component's language
* file to explain why this plugin stores no data.
*
* @return string
*/
public static function get_reason() : string {
public static function get_reason(): string {
return 'privacy:metadata';
}
}
5 changes: 2 additions & 3 deletions classes/reportbuilder/datasource/payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

declare(strict_types = 1);
declare(strict_types=1);

namespace report_payments\reportbuilder\datasource;

Expand All @@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class payments extends datasource {

/**
* Initialise report
*/
Expand Down Expand Up @@ -71,7 +70,7 @@ protected function initialise(): void {
));

$this->add_entity($course->add_join(
"LEFT JOIN {course} {$coursealias} ON {$coursealias}.id = {$enrolalias}.courseid"
"LEFT JOIN {course} {$coursealias} ON {$coursealias}.id = {$enrolalias}.courseid"
));

$this->add_columns_from_entity($mainname);
Expand Down
5 changes: 2 additions & 3 deletions classes/reportbuilder/local/entities/payment.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class payment extends base {

/**
* Database tables that this entity uses and their default aliases
*
Expand Down Expand Up @@ -149,13 +148,13 @@ protected function get_all_filters(): array {
$tablealias = $this->get_table_alias('payments');
$name = $this->get_entity_name();

$ownermethod = static function(): array {
$ownermethod = static function (): array {
global $DB;
return $DB->get_records_menu('payment_accounts', ['enabled' => true]);
};

// Name filter.
$filters[] = (new filter(select::class, 'accountid', new lang_string('name'), $name, "{$tablealias}.accountid"))
$filters[] = (new filter(select::class, 'accountid', new lang_string('name'), $name, "{$tablealias}.accountid"))
->add_joins($this->get_joins())
->set_options_callback($ownermethod);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class payments_course extends system_report {

/**
* Initialise report, we need to set the main table, load our entities and set columns/filters
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class payments_global extends system_report {

/**
* Initialise report, we need to set the main table, load our entities and set columns/filters
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class payments_user extends system_report {

/**
* Initialise report, we need to set the main table, load our entities and set columns/filters
*/
Expand Down
58 changes: 58 additions & 0 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="../../lib/phpunit/phpunit.xsd"
bootstrap="../../lib/phpunit/bootstrap.php"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
convertWarningsToExceptions="true"
processIsolation="false"
backupGlobals="false"
backupStaticAttributes="false"
cacheResult="false"
stopOnError="false"
stopOnFailure="false"
stopOnIncomplete="false"
stopOnSkipped="false"
beStrictAboutTestsThatDoNotTestAnything="false"
beStrictAboutOutputDuringTests="true"
>

<php>
<!--<const name="PHPUNIT_LONGTEST" value="1"/> uncomment to execute also slow or otherwise expensive tests-->
<const name="PHPUNIT_SEQUENCE_START" value="145000"/>

<!--Following constants instruct tests to fetch external test files from alternative location
or skip tests if empty, clone https://github.com/moodlehq/moodle-exttests to local web server-->
<!--<const name="TEST_EXTERNAL_FILES_HTTP_URL" value="http://download.moodle.org/unittest"/>
uncomment and alter to fetch external test files from alternative location-->
<!--<const name="TEST_EXTERNAL_FILES_HTTPS_URL" value="https://download.moodle.org/unittest"/>
uncomment and alter to fetch external test files from alternative location-->
</php>

<testsuites>
<testsuite name="report_payments_testsuite">
<directory suffix="_test.php">.</directory>
</testsuite>
</testsuites>

<coverage>
<include>
<directory suffix=".php">classes</directory>
<directory suffix=".php">tests/generator</directory>
<file>externallib.php</file>
<file>lib.php</file>
<file>locallib.php</file>
<file>renderer.php</file>
<file>rsslib.php</file>
</include>
<exclude>
<directory suffix=".php">db</directory>
<directory suffix=".php">lang</directory>
<directory suffix=".php">tests</directory>
<file>version.php</file>
<file>lib.php</file>
</exclude>
</coverage>

</phpunit>
Binary file added pix/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,6 @@
'reportpayments',
get_string('payments'),
$CFG->wwwroot . '/report/payments/index.php',
'report/payments:overview'));
'report/payments:overview'
));
$settings = null;
3 changes: 1 addition & 2 deletions tests/behat/behat_report_payments.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

require_once(__DIR__ . '/../../../../lib/behat/behat_base.php');

use Behat\Mink\Exception\ElementNotFoundException as ElementNotFoundException;
use Behat\Mink\Exception\ElementNotFoundException;

/**
* Step definitions to process a payment
Expand All @@ -39,7 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_report_payments extends behat_base {

/**
* Pay for a course
* @Then /^I pay for course "(?P<course>[^"]*)"$/
Expand Down
1 change: 0 additions & 1 deletion tests/coverage.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,3 @@
/** @var array The list of files relative to the plugin root to exclude from coverage generation. */
protected $excludelistfiles = ['version.php', 'lib.php'];
};

3 changes: 1 addition & 2 deletions tests/event/event_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class event_test extends \advanced_testcase {

/**
* Setup testcase.
*/
public function setUp():void {
public function setUp(): void {
$this->setAdminUser();
$this->resetAfterTest();
}
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<php>
<!--<const name="PHPUNIT_LONGTEST" value="1"/> uncomment to execute also slow or otherwise expensive tests-->
<const name="PHPUNIT_SEQUENCE_START" value="133000"/>
<const name="PHPUNIT_SEQUENCE_START" value="145000"/>

<!--Following constants instruct tests to fetch external test files from alternative location
or skip tests if empty, clone https://github.com/moodlehq/moodle-exttests to local web server-->
Expand Down
1 change: 0 additions & 1 deletion tests/privacy/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class privacy_test extends provider_testcase {

/**
* Test returning metadata.
* @covers \report_payments\privacy\provider
Expand Down
4 changes: 1 addition & 3 deletions tests/reportbuilder/reports_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class reports_test extends \advanced_testcase {

/** @var stdClass Course. */
private $course;

Expand All @@ -49,7 +48,7 @@ class reports_test extends \advanced_testcase {
/**
* Setup testcase.
*/
public function setUp():void {
public function setUp(): void {
global $DB;
$this->setAdminUser();
$this->resetAfterTest();
Expand Down Expand Up @@ -130,5 +129,4 @@ public function test_datasource() {
$preport = new payments($report);
$this->assertEquals($preport->get_name(), 'Payments');
}

}
1 change: 0 additions & 1 deletion version.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@
$plugin->supported = [401, 403];
$plugin->release = 'v1.0.6';
$plugin->version = 2023101400;

0 comments on commit a1c9264

Please sign in to comment.