blob: 9fc225c6a94ee3a699e5e0db04454457dcc78258 (
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
|
<?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\CoreUpdater\tests\Mock;
use Piwik\Plugins\CoreUpdater\ArchiveDownloadException;
use Piwik\Plugins\CoreUpdater\Updater;
use Piwik\Translation\Translator;
class UpdaterMock extends Updater
{
/**
* @var Translator
*/
private $translator;
public function __construct(Translator $translator)
{
$this->translator = $translator;
}
public function getLatestVersion()
{
return '40.0.0';
}
public function isNewVersionAvailable()
{
return true;
}
public function getArchiveUrl($version, $https = true)
{
return 'http://builds.matomo.org/piwik.zip';
}
public function updatePiwik($https = true)
{
// Simulate that the update over HTTPS fails
if ($https) {
// The actual error message depends on the OS, the HTTP method etc.
// This is what I get on my machine, but it doesn't really matter
throw new ArchiveDownloadException(new \Exception('curl_exec: SSL certificate problem: Invalid certificate chain. Hostname requested was: piwik.org'), array());
}
// Simulate that the update over HTTP succeeds
return array(
$this->translator->translate('CoreUpdater_DownloadingUpdateFromX', ''),
$this->translator->translate('CoreUpdater_UnpackingTheUpdate'),
$this->translator->translate('CoreUpdater_VerifyingUnpackedFiles'),
$this->translator->translate('CoreUpdater_InstallingTheLatestVersion'),
);
}
}
|