Proyectos de Subversion Moodle

Rev

Rev 11 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 11 Rev 1441
Línea 29... Línea 29...
29
 *
29
 *
30
 * @package    mod_forum
30
 * @package    mod_forum
31
 * @copyright  2013 Frédéric Massart
31
 * @copyright  2013 Frédéric Massart
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
32
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
33
 */
33
 */
34
class subscriptions_test extends \advanced_testcase {
34
final class subscriptions_test extends \advanced_testcase {
35
    // Include the mod_forum test helpers.
35
    // Include the mod_forum test helpers.
36
    // This includes functions to create forums, users, discussions, and posts.
36
    // This includes functions to create forums, users, discussions, and posts.
37
    use mod_forum_tests_generator_trait;
37
    use mod_forum_tests_generator_trait;
Línea 38... Línea 38...
38
 
38
 
39
    /**
39
    /**
40
     * Test setUp.
40
     * Test setUp.
41
     */
41
     */
42
    public function setUp(): void {
42
    public function setUp(): void {
-
 
43
        global $DB;
Línea 43... Línea 44...
43
        global $DB;
44
        parent::setUp();
44
 
45
 
45
        // We must clear the subscription caches. This has to be done both before each test, and after in case of other
46
        // We must clear the subscription caches. This has to be done both before each test, and after in case of other
46
        // tests using these functions.
47
        // tests using these functions.
Línea 54... Línea 55...
54
    public function tearDown(): void {
55
    public function tearDown(): void {
55
        // We must clear the subscription caches. This has to be done both before each test, and after in case of other
56
        // We must clear the subscription caches. This has to be done both before each test, and after in case of other
56
        // tests using these functions.
57
        // tests using these functions.
57
        \mod_forum\subscriptions::reset_forum_cache();
58
        \mod_forum\subscriptions::reset_forum_cache();
58
        \mod_forum\subscriptions::reset_discussion_cache();
59
        \mod_forum\subscriptions::reset_discussion_cache();
-
 
60
        parent::tearDown();
59
    }
61
    }
Línea 60... Línea 62...
60
 
62
 
61
    /**
63
    /**
62
     * Test subscription modes modifications.
64
     * Test subscription modes modifications.
Línea 1351... Línea 1353...
1351
 
1353
 
1352
        // There should be more queries than when we performed the same check a moment ago.
1354
        // There should be more queries than when we performed the same check a moment ago.
1353
        $this->assertGreaterThan($suppliedcmcount, $calculatedcmcount);
1355
        $this->assertGreaterThan($suppliedcmcount, $calculatedcmcount);
Línea 1354... Línea 1356...
1354
    }
1356
    }
1355
 
1357
 
1356
    public function is_subscribable_forums() {
1358
    public static function is_subscribable_forums(): array {
1357
        return [
1359
        return [
1358
            [
1360
            [
1359
                'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE,
1361
                'forcesubscribe' => FORUM_DISALLOWSUBSCRIBE,
Línea 1368... Línea 1370...
1368
                'forcesubscribe' => FORUM_FORCESUBSCRIBE,
1370
                'forcesubscribe' => FORUM_FORCESUBSCRIBE,
1369
            ],
1371
            ],
1370
        ];
1372
        ];
1371
    }
1373
    }
Línea 1372... Línea 1374...
1372
 
1374
 
1373
    public function is_subscribable_provider() {
1375
    public static function is_subscribable_provider(): array {
1374
        $data = [];
1376
        $data = [];
1375
        foreach ($this->is_subscribable_forums() as $forum) {
1377
        foreach (self::is_subscribable_forums() as $forum) {
1376
            $data[] = [$forum];
1378
            $data[] = [$forum];
Línea 1377... Línea 1379...
1377
        }
1379
        }
1378
 
1380
 
Línea 1409... Línea 1411...
1409
        $forum = $this->getDataGenerator()->create_module('forum', $options);
1411
        $forum = $this->getDataGenerator()->create_module('forum', $options);
Línea 1410... Línea 1412...
1410
 
1412
 
1411
        $this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
1413
        $this->assertFalse(\mod_forum\subscriptions::is_subscribable($forum));
Línea 1412... Línea 1414...
1412
    }
1414
    }
1413
 
1415
 
1414
    public function is_subscribable_loggedin_provider() {
1416
    public static function is_subscribable_loggedin_provider(): array {
1415
        return [
1417
        return [
1416
            [
1418
            [
1417
                ['forcesubscribe' => FORUM_DISALLOWSUBSCRIBE],
1419
                ['forcesubscribe' => FORUM_DISALLOWSUBSCRIBE],