Welcome to mirror list, hosted at ThFree Co, Russian Federation.

Remote.php « Runner « TestRunner « plugins - github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: d068aa2f93f4cd7be07fc38ff479b198e097c744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/**
 * Piwik - free/libre analytics platform
 *
 * @link http://piwik.org
 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
 *
 */

namespace Piwik\Plugins\TestRunner\Runner;

use \Net_SSH2;

class Remote
{
    /**
     * @var \Net_SSH2
     */
    private $ssh;

    public function __construct(Net_SSH2 $ssh)
    {
        $this->ssh = $ssh;
    }

    public function updatePiwik($gitHash)
    {
        $this->ssh->exec('git reset --hard');
        $this->ssh->exec('git clean -d -f');
        $this->ssh->exec('git fetch --all');
        $this->ssh->exec('git checkout ' . trim($gitHash));
        $this->ssh->exec('sudo composer.phar self-update');
        $this->ssh->exec('composer.phar install');
    }

    public function runTests($host, $testSuite)
    {
        $this->prepareTestRun($host);
        $this->printVersionInfo();
        $this->doRunTests($testSuite);
    }

    private function prepareTestRun($host)
    {
        $this->ssh->exec('cp ./tests/PHPUnit/phpunit.xml.dist ./tests/PHPUnit/phpunit.xml');
        $this->ssh->exec("sed -i 's/@REQUEST_URI@/\\//g' ./tests/PHPUnit/phpunit.xml");
        $this->ssh->exec("sed -i 's/amazonAwsUrl/$host/g' ./config/config.ini.php");
    }

    private function printVersionInfo()
    {
        $this->ssh->exec('php --version');
        $this->ssh->exec('mysql --version');
        $this->ssh->exec('phantomjs --version');
    }

    private function doRunTests($testSuite)
    {
        if ('all' === $testSuite) {
            $this->ssh->exec('php console tests:run --options="--colors"');
        } elseif ('ui' === $testSuite) {
            $this->ssh->exec('php console tests:run-ui');
        } else {
            $this->ssh->exec('php console tests:run --options="--colors" --testsuite="unit"');
            $this->ssh->exec('php console tests:run --options="--colors" --testsuite="' . $testSuite . '"');
        }
    }
}