xref: /plugin/upgrade/_test/version.test.php (revision 4e3e87e45b11e1184e5fb1995e14bdc3ab70ccf5)
10ab52135SAndreas Gohr<?php
20ab52135SAndreas Gohr
30ab52135SAndreas Gohr/**
40ab52135SAndreas Gohr * Version parsing tests for the upgrade plugin
50ab52135SAndreas Gohr *
60ab52135SAndreas Gohr * @group plugin_upgrade
70ab52135SAndreas Gohr * @group plugins
80ab52135SAndreas Gohr */
90ab52135SAndreas Gohrclass version_plugin_upgrade_test extends DokuWikiTest
100ab52135SAndreas Gohr{
110ab52135SAndreas Gohr    /**
120ab52135SAndreas Gohr     * @return array
130ab52135SAndreas Gohr     * @see testVersions
140ab52135SAndreas Gohr     */
150ab52135SAndreas Gohr    public function provideVersions()
160ab52135SAndreas Gohr    {
170ab52135SAndreas Gohr        return [
180ab52135SAndreas Gohr            ['2018-04-22c "Greebo"', '2018-04-22'],
190ab52135SAndreas Gohr            ['rc2020-06-01 "Hogfather"', '2020-06-01'],
200ab52135SAndreas Gohr            ['rc2-2020-06-01 "Hogfather" RC2', '2020-06-01'],
210ab52135SAndreas Gohr            ['Git 2020-06-03', '2020-06-03'],
220ab52135SAndreas Gohr            ['rc2013-11-18 "Binky RC2"', '2013-11-18'],
230ab52135SAndreas Gohr            ['foobar', 0],
240ab52135SAndreas Gohr        ];
250ab52135SAndreas Gohr    }
260ab52135SAndreas Gohr
270ab52135SAndreas Gohr    /**
280ab52135SAndreas Gohr     * @dataProvider provideVersions
290ab52135SAndreas Gohr     * @param string $version
300ab52135SAndreas Gohr     * @param string $expected
310ab52135SAndreas Gohr     */
320ab52135SAndreas Gohr    public function testVersions($version, $expected)
330ab52135SAndreas Gohr    {
34*4e3e87e4SAndreas Gohr        $plugin = new helper_plugin_upgrade();
350ab52135SAndreas Gohr
36*4e3e87e4SAndreas Gohr        $result = $this->callInaccessibleMethod($plugin, 'dateFromVersion', [$version]);
37*4e3e87e4SAndreas Gohr        $this->assertSame($expected, $result);
380ab52135SAndreas Gohr    }
390ab52135SAndreas Gohr
400ab52135SAndreas Gohr}
41