1<?php
2
3/**
4 * General tests for the watchcycle plugin
5 *
6 * @group plugin_watchcycle
7 * @group plugins
8 */
9class maintainer_plugin_watchcycle_test extends DokuWikiTest
10{
11
12    protected $pluginsEnabled = ['watchcycle'];
13
14    /**
15     * copy over our own test users
16     * @inheritDoc
17     */
18    public static function setUpBeforeClass(): void
19    {
20        parent::setUpBeforeClass();
21        TestUtils::rcopy(TMP_DIR, __DIR__ . '/conf');
22    }
23
24
25    public function test_getMaintainer()
26    {
27        $input = 'foo, bar, testuser1, @baz, @other';
28        $output = [
29            'foo' => false,
30            'bar' => false,
31            'testuser1' => [
32                'name' => 'TestUser1',
33                'mail' => 'test1@example.com',
34                'pass' => '179ad45c6ce2cb97cf1029e212046e81',
35                'grps' => ['user', 'other']
36            ],
37            '@baz' => null,
38            '@other' => null,
39        ];
40
41
42        /** @var helper_plugin_watchcycle $helper */
43        $helper = plugin_load('helper', 'watchcycle');
44        $this->assertEquals($output, $helper->getMaintainers($input));
45    }
46
47    public function test_getMaintainerMails()
48    {
49        $input = 'foo, bar, testuser1, @baz, @other';
50        $output = ['test1@example.com', 'test2@example.com'];
51
52        /** @var helper_plugin_watchcycle $helper */
53        $helper = plugin_load('helper', 'watchcycle');
54        $this->assertEquals($output, $helper->getMaintainerMails($input));
55    }
56}
57