diff options
Diffstat (limited to 'tests/PHPUnit/Integration')
-rw-r--r-- | tests/PHPUnit/Integration/DbHelperTest.php | 48 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/HttpTest.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/JsProxyTest.php | 6 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/ReleaseCheckListTest.php | 9 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php | 30 |
5 files changed, 78 insertions, 21 deletions
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;`'; diff --git a/tests/PHPUnit/Integration/HttpTest.php b/tests/PHPUnit/Integration/HttpTest.php index 1e9a734dc7..d7831f5021 100644 --- a/tests/PHPUnit/Integration/HttpTest.php +++ b/tests/PHPUnit/Integration/HttpTest.php @@ -35,8 +35,8 @@ class HttpTest extends \PHPUnit_Framework_TestCase public function testFetchRemoteFile($method) { $this->assertNotNull(Http::getTransportMethod()); - $result = Http::sendHttpRequestBy($method, Fixture::getRootUrl() . 'piwik.js', 30); - $this->assertTrue(strpos($result, 'Piwik') !== false); + $result = Http::sendHttpRequestBy($method, Fixture::getRootUrl() . 'matomo.js', 30); + $this->assertTrue(strpos($result, 'Matomo') !== false); } public function testFetchApiLatestVersion() @@ -73,7 +73,7 @@ class HttpTest extends \PHPUnit_Framework_TestCase $result = Http::sendHttpRequestBy( $method, - Fixture::getRootUrl() . '/piwik.js', + Fixture::getRootUrl() . '/matomo.js', 30, $userAgent = null, $destinationPath = null, diff --git a/tests/PHPUnit/Integration/JsProxyTest.php b/tests/PHPUnit/Integration/JsProxyTest.php index 17e2430401..c1ff170166 100644 --- a/tests/PHPUnit/Integration/JsProxyTest.php +++ b/tests/PHPUnit/Integration/JsProxyTest.php @@ -22,7 +22,7 @@ class JsProxyTest extends IntegrationTestCase Fixture::createWebsite('2014-01-01 02:03:04'); } - public function testPiwikJs() + public function testMatomoJs() { $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $this->getStaticSrvUrl() . '/js/'); @@ -33,7 +33,7 @@ class JsProxyTest extends IntegrationTestCase $this->assertEquals(200, $responseInfo["http_code"], 'Ok response'); - $piwik_js = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/piwik.js'); + $piwik_js = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/matomo.js'); $this->assertEquals($piwik_js, $fullResponse, 'script content'); } @@ -48,7 +48,7 @@ class JsProxyTest extends IntegrationTestCase $this->assertEquals(200, $responseInfo["http_code"], 'Ok response'); - $piwikJs = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/piwik.js'); + $piwikJs = file_get_contents(PIWIK_PATH_TEST_TO_ROOT . '/matomo.js'); $piwikNoCommentJs = substr($piwikJs, strpos($piwikJs, "*/\n") + 3); $this->assertEquals($piwikNoCommentJs, trim($fullResponse), 'script content (if comment shows, $byteStart value in /js/tracker.php)'); } diff --git a/tests/PHPUnit/Integration/ReleaseCheckListTest.php b/tests/PHPUnit/Integration/ReleaseCheckListTest.php index bce8b56c24..0fb62a64c5 100644 --- a/tests/PHPUnit/Integration/ReleaseCheckListTest.php +++ b/tests/PHPUnit/Integration/ReleaseCheckListTest.php @@ -492,6 +492,15 @@ class ReleaseCheckListTest extends \PHPUnit_Framework_TestCase ); } + public function test_piwikJs_SameAsMatomoJs() + { + $this->assertFileEquals( + PIWIK_DOCUMENT_ROOT . '/matomo.js', + PIWIK_DOCUMENT_ROOT . '/piwik.js', + '/piwik.js does not match /matomo.js, please re-generate the minified files using instructions in /js/README' + ); + } + public function testTmpDirectoryContainsGitKeep() { $this->assertFileExists(PIWIK_DOCUMENT_ROOT . '/tmp/.gitkeep'); diff --git a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php index 3827303374..2e9ee543b3 100644 --- a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php +++ b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php @@ -57,13 +57,13 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['enableLinkTracking']); (function() { var u="//piwik-server/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> -<noscript><p><img src="//piwik-server/piwik/piwik.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript> +<noscript><p><img src="//piwik-server/piwik/matomo.php?idsite=1&amp;rec=1" style="border:0;" alt="" /></p></noscript> <!-- End Matomo Code --> "; @@ -84,10 +84,10 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['enableLinkTracking']); (function() { var u="//localhost/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -131,10 +131,10 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['enableLinkTracking']); (function() { var u="https://localhost/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -179,10 +179,10 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase (function() { var u="//localhost/piwik/"; _paq.push(['setAPIUrl', 'http://localhost/statistics']); - _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; - g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s); + g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -214,12 +214,12 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push(['enableLinkTracking']); (function() { var u="//localhost/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.php']); + _paq.push(['setTrackerUrl', u+'matomo.php']); _paq.push(['setSiteId', '1']); })(); </script> -<script type='text/javascript' src="//localhost/piwik/piwik.js"></script> +<script type='text/javascript' src="//localhost/piwik/matomo.js"></script> <!-- End Matomo Code --> "; @@ -257,10 +257,10 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push([\'enableLinkTracking\']); (function() { var u="//abc"def/"; - _paq.push([\'setTrackerUrl\', u+\'piwik.php\']); + _paq.push([\'setTrackerUrl\', u+\'matomo.php\']); _paq.push([\'setSiteId\', \'1\']); var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0]; - g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'piwik.js\'; s.parentNode.insertBefore(g,s); + g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> @@ -284,10 +284,10 @@ class TrackerCodeGeneratorTest extends IntegrationTestCase _paq.push([\'enableLinkTracking\']); (function() { var u="https://localhost/piwik/"; - _paq.push([\'setTrackerUrl\', u+\'piwik.php\']); + _paq.push([\'setTrackerUrl\', u+\'matomo.php\']); _paq.push([\'setSiteId\', \'1\']); var d=document, g=d.createElement(\'script\'), s=d.getElementsByTagName(\'script\')[0]; - g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'piwik.js\'; s.parentNode.insertBefore(g,s); + g.type=\'text/javascript\'; g.async=true; g.defer=true; g.src=u+\'matomo.js\'; s.parentNode.insertBefore(g,s); })(); </script> <!-- End Matomo Code --> |