xref: /dokuwiki/_test/tests/inc/infoutils_getversiondata.test.php (revision e5358e0d3f36623db1a07144a87eac720232d466)
1*e5358e0dSAndreas Gohr<?php
2*e5358e0dSAndreas Gohr
3*e5358e0dSAndreas Gohrclass infoutils_getversiondata_test extends DokuWikiTest {
4*e5358e0dSAndreas Gohr
5*e5358e0dSAndreas Gohr    /**
6*e5358e0dSAndreas Gohr     * On a git checkout the reported date and hash must be well-formed.
7*e5358e0dSAndreas Gohr     *
8*e5358e0dSAndreas Gohr     * The git call uses --pretty=reference to avoid percent placeholders: on
9*e5358e0dSAndreas Gohr     * Windows escapeshellarg() replaces them with spaces, so the old
10*e5358e0dSAndreas Gohr     * "--pretty=format:%h %cd" command made git echo literal text and
11*e5358e0dSAndreas Gohr     * getVersionData() reported date "h" with an empty hash. This test runs on
12*e5358e0dSAndreas Gohr     * the Windows CI too, where that old behaviour would fail these assertions.
13*e5358e0dSAndreas Gohr     */
14*e5358e0dSAndreas Gohr    function test_gitVersionIsWellFormed() {
15*e5358e0dSAndreas Gohr        $version = getVersionData();
16*e5358e0dSAndreas Gohr        if ($version['type'] !== 'Git') {
17*e5358e0dSAndreas Gohr            $this->markTestSkipped('not running from a git checkout');
18*e5358e0dSAndreas Gohr        }
19*e5358e0dSAndreas Gohr
20*e5358e0dSAndreas Gohr        $this->assertMatchesRegularExpression('/^\d{4}-\d{2}-\d{2}$/', $version['date']);
21*e5358e0dSAndreas Gohr        $this->assertMatchesRegularExpression('/^[0-9a-f]{7,40}$/', $version['sha']);
22*e5358e0dSAndreas Gohr    }
23*e5358e0dSAndreas Gohr}
24