From 73010596f01b9660899267305fe0cf5064428753 Mon Sep 17 00:00:00 2001 From: Thomas Steur Date: Thu, 29 Nov 2018 20:22:15 +1300 Subject: Make matomo.js and matomo.php the default Tracking API endpoints used (#13596) * Make matomo.js and matomo.php the default Tracking API endpoints used * few fixes * fix few tests * update matomo php tracker in composer * make sure to record install version * do not overwrite ever install version * trying to fix test * more tweaks and fix tests * prefer matomo endpoint in the ui, fix some tests * file was still needed * apply review feedback * fix ui tests --- tests/PHPUnit/Integration/DbHelperTest.php | 48 ++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) (limited to 'tests/PHPUnit/Integration/DbHelperTest.php') diff --git a/tests/PHPUnit/Integration/DbHelperTest.php b/tests/PHPUnit/Integration/DbHelperTest.php index f8268f451c..5b88015eab 100644 --- a/tests/PHPUnit/Integration/DbHelperTest.php +++ b/tests/PHPUnit/Integration/DbHelperTest.php @@ -10,7 +10,9 @@ namespace Piwik\Tests\Integration; use Piwik\Db; use Piwik\DbHelper; +use Piwik\Option; use Piwik\Tests\Framework\TestCase\IntegrationTestCase; +use Piwik\Version; class DbHelperTest extends IntegrationTestCase { @@ -22,6 +24,52 @@ class DbHelperTest extends IntegrationTestCase DbHelper::dropDatabase('testdb'); } + public function test_getInstallVersion_isCurrentVersion() + { + $this->assertSame(Version::VERSION, DbHelper::getInstallVersion()); + } + + public function test_recordInstallVersion_setsCurrentVersion() + { + Option::delete(Db\Schema\Mysql::OPTION_NAME_MATOMO_INSTALL_VERSION); + $this->assertNull(DbHelper::getInstallVersion()); + + DbHelper::recordInstallVersion(); + $this->assertSame(Version::VERSION, DbHelper::getInstallVersion()); + } + + public function test_recordInstallVersion_doesNotOverwritePreviouslySetVersion() + { + $this->setInstallVersion('2.1.0'); + DbHelper::recordInstallVersion(); + DbHelper::recordInstallVersion(); + DbHelper::recordInstallVersion(); + $this->assertSame('2.1.0', DbHelper::getInstallVersion()); + } + + public function test_wasMatomoInstalledBeforeVersion_sameVersion() + { + $this->setInstallVersion('2.1.0'); + $this->assertFalse(DbHelper::wasMatomoInstalledBeforeVersion('2.1.0')); + } + + public function test_wasMatomoInstalledBeforeVersion_whenUsedNewerVersion() + { + $this->setInstallVersion('2.1.0'); + $this->assertFalse(DbHelper::wasMatomoInstalledBeforeVersion('2.0.0')); + } + + public function test_wasMatomoInstalledBeforeVersion_whenWasInstalledBeforeThatVersion() + { + $this->setInstallVersion('2.1.0'); + $this->assertTrue(DbHelper::wasMatomoInstalledBeforeVersion('2.2.0')); + } + + private function setInstallVersion($version) + { + Option::set(Db\Schema\Mysql::OPTION_NAME_MATOMO_INSTALL_VERSION, $version); + } + public function test_createDatabase_escapesInputProperly() { $dbName = 'newdb`; create database anotherdb;`'; -- cgit v1.2.3