Skip to content

Commit

Permalink
phpunit upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
ewallah committed Oct 23, 2020
1 parent ca64547 commit 8b1f05f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 20 deletions.
11 changes: 4 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,18 @@ cache:
- $HOME/.nvm

php:
- 7.3
- 7.4

env:
- DB=pgsql MOODLE_BRANCH=master
- DB=mysqli MOODLE_BRANCH=master

jobs:
include:
- php: 7.2
env: DB=mysqli MOODLE_BRANCH=MOODLE_37_STABLE
- env: DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE
- php: 7.3
env: DB=mysqli MOODLE_BRANCH=MOODLE_38_STABLE
- env: DB=mysqli MOODLE_BRANCH=MOODLE_39_STABLE
- env: DB=mysqli MOODLE_BRANCH=MOODLE_310_STABLE
- php: 7.4
env: DB=mysqli MOODLE_BRANCH=master

before_install:
- phpenv config-rm xdebug.ini
Expand Down Expand Up @@ -62,7 +59,7 @@ script:
- moodle-plugin-ci behat --suite="classic"
- moodle-plugin-ci behat --suite="classic" --profile chrome
- moodle-plugin-ci behat --suite="classic" --profile chrome blocks/admin_bookmarks
- vendor/bin/phpunit --testsuite core_privacy_testsuite,tool_dataprivacy_testsuite
- vendor/bin/phpunit --testsuite core_privacy_testsuite,tool_dataprivacy_testsuite > /dev/null

after_success:
- moodle-plugin-ci coveralls-upload
1 change: 0 additions & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
<directory suffix=".php">tests</directory>
<directory suffix=".php">lang/en</directory>
<file>version.php</file>
<file>tests/coverage.php</file>
</exclude>
</whitelist>

Expand Down
16 changes: 8 additions & 8 deletions tests/condition_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ class availability_coursecompleted_testcase extends advanced_testcase {
/**
* Load required classes.
*/
public function setUp() {
public function setUp():void {
// Load the mock info class so that it can be used.
global $CFG;
require_once($CFG->dirroot . '/availability/tests/fixtures/mock_info.php');
Expand Down Expand Up @@ -131,7 +131,7 @@ public function test_constructor() {
$completed = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid value for course completed condition', $e->getMessage());
$this->assertStringContainsString('Invalid value for course completed condition', $e->getMessage());
}

// Invalid ->id.
Expand All @@ -140,7 +140,7 @@ public function test_constructor() {
$completed = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid value for course completed condition', $e->getMessage());
$this->assertStringContainsString('Invalid value for course completed condition', $e->getMessage());
}

// Invalid string. Should be checked 'longer string'.
Expand All @@ -149,7 +149,7 @@ public function test_constructor() {
$completed = new condition($structure);
$this->fail();
} catch (coding_exception $e) {
$this->assertContains('Invalid value for course completed condition', $e->getMessage());
$this->assertStringContainsString('Invalid value for course completed condition', $e->getMessage());
}
}

Expand Down Expand Up @@ -182,10 +182,10 @@ public function test_get_description() {
$class = new ReflectionClass('availability_coursecompleted\frontend');
$method = $class->getMethod('get_javascript_strings');
$method->setAccessible(true);
$this->assertEquals([], $method->invokeArgs($frontend, []));
$this->assertEqualsCanonicalizing([], $method->invokeArgs($frontend, []));
$method = $class->getMethod('get_javascript_init_params');
$method->setAccessible(true);
$this->assertEquals(0, count($method->invokeArgs($frontend, [$course])));
$this->assertCount(0, $method->invokeArgs($frontend, [$course]));
$method = $class->getMethod('allow_add');
$method->setAccessible(true);
$this->assertTrue($method->invokeArgs($frontend, [$course, null, null]));
Expand Down Expand Up @@ -263,8 +263,8 @@ public function test_page() {
*/
public function test_other() {
$condition = \availability_coursecompleted\condition::get_json('3');
$this->assertEquals($condition, (object)['type' => 'coursecompleted', 'id' => '3']);
$this->assertEqualsCanonicalizing((object)['type' => 'coursecompleted', 'id' => '3'], $condition);
$condition = \availability_coursecompleted\condition::get_json('0');
$this->assertEquals($condition, (object)['type' => 'coursecompleted', 'id' => '0']);
$this->assertEqualsCanonicalizing((object)['type' => 'coursecompleted', 'id' => '0'], $condition);
}
}
8 changes: 4 additions & 4 deletions tests/privacy_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/

namespace availability_coursecompleted\privacy;

defined('MOODLE_INTERNAL') || die();

use \core_privacy\tests\provider_testcase;
Expand All @@ -33,18 +35,16 @@
* @copyright 2017 eWallah.net <info@eWallah.net>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class availability_coursecompleted_privacy_testcase extends provider_testcase {
class privacy_testcase extends provider_testcase {

/**
* Test returning metadata.
* @coversDefaultClass availability_coursecompleted\privacy\provider
*/
public function test_get_metadata() {
$this->resetAfterTest(true);
$collection = new \core_privacy\local\metadata\collection('availability_coursecompleted');
$reason = \availability_coursecompleted\privacy\provider::get_reason($collection);
$this->assertEquals($reason, 'privacy:metadata');
$str = 'does not store';
$this->assertContains($str, get_string($reason, 'availability_coursecompleted'));
$this->assertStringContainsString('does not store', get_string($reason, 'availability_coursecompleted'));
}
}

0 comments on commit 8b1f05f

Please sign in to comment.