diff options
author | Matthieu Aubry <matt@piwik.org> | 2015-03-16 07:53:20 +0300 |
---|---|---|
committer | Matthieu Aubry <matt@piwik.org> | 2015-03-16 07:53:20 +0300 |
commit | 57d3e10376bdde32e4c03c647144ee56e4f57075 (patch) | |
tree | 5937e95068de5e40f48b43f9f611f08754e3fe7b /tests | |
parent | ccddd801de4cb76b5a95375e54f1bfcf0fe4f6c1 (diff) | |
parent | 15d69e7a7ef02508c7a89d15794f9159c95e9928 (diff) |
Merge pull request #7429 from piwik/https-update
When failing to update over HTTPS, let the user update over HTTP
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Framework/Fixture.php | 10 | ||||
-rw-r--r-- | tests/PHPUnit/TestingEnvironment.php | 15 | ||||
-rw-r--r-- | tests/UI/Fixtures/UpdaterTestFixture.php | 21 | ||||
m--------- | tests/UI/expected-ui-screenshots | 0 | ||||
-rw-r--r-- | tests/UI/specs/CoreUpdaterCode_spec.js | 34 | ||||
-rw-r--r-- | tests/UI/specs/CoreUpdaterDb_spec.js (renamed from tests/UI/specs/Updater_spec.js) | 6 | ||||
-rw-r--r-- | tests/lib/screenshot-testing/support/test-environment.js | 3 |
7 files changed, 65 insertions, 24 deletions
diff --git a/tests/PHPUnit/Framework/Fixture.php b/tests/PHPUnit/Framework/Fixture.php index d5f9aa397c..302d1192e2 100644 --- a/tests/PHPUnit/Framework/Fixture.php +++ b/tests/PHPUnit/Framework/Fixture.php @@ -882,4 +882,14 @@ class Fixture extends \PHPUnit_Framework_Assert return $result; } + + /** + * Use this method to return custom container configuration that you want to apply for the tests. + * + * @return array + */ + public function provideContainerConfig() + { + return array(); + } } diff --git a/tests/PHPUnit/TestingEnvironment.php b/tests/PHPUnit/TestingEnvironment.php index 97d98dbff8..3acc202a91 100644 --- a/tests/PHPUnit/TestingEnvironment.php +++ b/tests/PHPUnit/TestingEnvironment.php @@ -2,10 +2,12 @@ use Piwik\Common; use Piwik\Config; +use Piwik\Container\StaticContainer; use Piwik\Piwik; use Piwik\Option; use Piwik\Plugin\Manager as PluginManager; use Piwik\DbHelper; +use Piwik\Tests\Framework\Fixture; require_once PIWIK_INCLUDE_PATH . "/core/Config.php"; @@ -148,6 +150,19 @@ class Piwik_TestingEnvironment $testingEnvironment->configFileGlobal, $testingEnvironment->configFileLocal, $testingEnvironment->configFileCommon )); + // Apply DI config from the fixture + if ($testingEnvironment->fixtureClass) { + $fixtureClass = $testingEnvironment->fixtureClass; + if (class_exists($fixtureClass)) { + /** @var Fixture $fixture */ + $fixture = new $fixtureClass; + $diConfig = $fixture->provideContainerConfig(); + if (!empty($diConfig)) { + StaticContainer::addDefinitions($diConfig); + } + } + } + \Piwik\Cache\Backend\File::$invalidateOpCacheBeforeRead = true; Piwik::addAction('Access.createAccessSingleton', function($access) use ($testingEnvironment) { diff --git a/tests/UI/Fixtures/UpdaterTestFixture.php b/tests/UI/Fixtures/UpdaterTestFixture.php deleted file mode 100644 index e2b3a0024e..0000000000 --- a/tests/UI/Fixtures/UpdaterTestFixture.php +++ /dev/null @@ -1,21 +0,0 @@ -<?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\Tests\Fixtures; - -class UpdaterTestFixture extends SqlDump -{ - public function performSetUp($setupEnvironmentOnly = false) - { - $this->dumpUrl = PIWIK_INCLUDE_PATH . "/tests/UI/resources/piwik1.0.sql.gz"; - $this->dropDatabaseInSetUp = true; - $this->resetPersistedFixture = true; - - parent::performSetUp($setupEnvironmentOnly); - } -}
\ No newline at end of file diff --git a/tests/UI/expected-ui-screenshots b/tests/UI/expected-ui-screenshots -Subproject 560c44710748f4f27ceaee0955f59aa1336ee4a +Subproject 8fe69f4a0708df35348bf701be916ad87d3761e diff --git a/tests/UI/specs/CoreUpdaterCode_spec.js b/tests/UI/specs/CoreUpdaterCode_spec.js new file mode 100644 index 0000000000..807810869b --- /dev/null +++ b/tests/UI/specs/CoreUpdaterCode_spec.js @@ -0,0 +1,34 @@ +/*! + * Piwik - free/libre analytics platform + * + * Installation screenshot tests. + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +describe("CoreUpdaterCode", function () { + this.timeout(0); + + this.fixture = "Piwik\\Plugins\\CoreUpdater\\Test\\Fixtures\\FailUpdateHttpsFixture"; + + var url = "?module=CoreUpdater&action=newVersionAvailable"; + + it("should show a new version is available", function (done) { + expect.screenshot("newVersion").to.be.capture(function (page) { + page.load(url); + }, done); + }); + + it("should offer to update over http when updating over https fails", function (done) { + expect.screenshot("httpsUpdateFail").to.be.capture(function (page) { + page.click('#updateAutomatically'); + }, done); + }); + + it("should show the update steps when updating over http succeeds", function (done) { + expect.screenshot("httpUpdateSuccess").to.be.capture(function (page) { + page.click('#updateUsingHttp'); + }, done); + }); +}); diff --git a/tests/UI/specs/Updater_spec.js b/tests/UI/specs/CoreUpdaterDb_spec.js index 0ddc8b67cb..f77776a4ca 100644 --- a/tests/UI/specs/Updater_spec.js +++ b/tests/UI/specs/CoreUpdaterDb_spec.js @@ -7,10 +7,10 @@ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later */ -describe("Updater", function () { +describe("CoreUpdaterDb", function () { this.timeout(0); - this.fixture = "Piwik\\Tests\\Fixtures\\UpdaterTestFixture"; + this.fixture = "Piwik\\Plugins\\CoreUpdater\\Test\\Fixtures\\DbUpdaterTestFixture"; before(function () { testEnvironment.tablesPrefix = 'piwik_'; @@ -34,4 +34,4 @@ describe("Updater", function () { page.click('.submit'); }, done); }); -});
\ No newline at end of file +}); diff --git a/tests/lib/screenshot-testing/support/test-environment.js b/tests/lib/screenshot-testing/support/test-environment.js index 9379ab88da..8a8dc183bf 100644 --- a/tests/lib/screenshot-testing/support/test-environment.js +++ b/tests/lib/screenshot-testing/support/test-environment.js @@ -153,6 +153,9 @@ TestingEnvironment.prototype.setupFixture = function (fixtureClass, done) { self.reload(); self.addPluginOnCmdLineToTestEnv(); + self.fixtureClass = fixtureClass; + self.save(); + console.log(); if (code) { |