diff options
author | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-17 08:26:31 +0400 |
---|---|---|
committer | Matthieu Napoli <matthieu@mnapoli.fr> | 2014-10-17 08:26:31 +0400 |
commit | 70adbfc090095e8ed80a6a0f1dcc9623d4cc1127 (patch) | |
tree | 1be9c97b52f15c60fa146cddc8090cd27ca8caf6 /tests | |
parent | c2d2d2812da959676b5f88230343076af3838d24 (diff) | |
parent | d76e38c70c86c5ae4414653f85ca64e2b67188db (diff) |
Merge branch 'master' into bugfix/6156
Diffstat (limited to 'tests')
-rw-r--r-- | tests/PHPUnit/Integration/DataAccess/ModelTest.php | 49 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/PiwikTest.php | 140 | ||||
-rw-r--r-- | tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php | 154 | ||||
m--------- | tests/PHPUnit/UI | 0 | ||||
-rw-r--r-- | tests/PHPUnit/Unit/CliMulti/ProcessTest.php | 5 | ||||
-rwxr-xr-x | tests/travis/travis.sh | 13 |
6 files changed, 209 insertions, 152 deletions
diff --git a/tests/PHPUnit/Integration/DataAccess/ModelTest.php b/tests/PHPUnit/Integration/DataAccess/ModelTest.php new file mode 100644 index 0000000000..62ccaeaade --- /dev/null +++ b/tests/PHPUnit/Integration/DataAccess/ModelTest.php @@ -0,0 +1,49 @@ +<?php +/** + * Piwik - free/libre analytics platform + * + * @link http://piwik.org + * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later + */ + +use Piwik\Tests\Framework\TestCase\IntegrationTestCase; +use Piwik\DataAccess\Model; + +/** + * @group Core + * @group DataAccess + */ +class Core_DataAccess_ModelTest extends IntegrationTestCase +{ + /** + * @var Model + */ + private $model; + private $tableName = 'archive_numeric_test'; + + public function setUp() + { + parent::setUp(); + + $this->model = new Model(); + $this->model->createArchiveTable($this->tableName, 'archive_numeric'); + } + + public function test_insertNewArchiveId() + { + $this->assertCreatedArchiveId(1); + $this->assertCreatedArchiveId(2); + $this->assertCreatedArchiveId(3); + $this->assertCreatedArchiveId(4); + $this->assertCreatedArchiveId(5, 2); + $this->assertCreatedArchiveId(6, 2); + } + + private function assertCreatedArchiveId($expectedId, $siteId = 1) + { + $id = $this->model->insertNewArchiveId($this->tableName, $siteId, '2014-01-01 00:01:02'); + + $this->assertEquals($expectedId, $id); + } + +}
\ No newline at end of file diff --git a/tests/PHPUnit/Integration/PiwikTest.php b/tests/PHPUnit/Integration/PiwikTest.php index f81aeae081..9e1bfdb95a 100644 --- a/tests/PHPUnit/Integration/PiwikTest.php +++ b/tests/PHPUnit/Integration/PiwikTest.php @@ -20,146 +20,6 @@ use Piwik\Tests\Framework\TestCase\IntegrationTestCase; */ class Core_PiwikTest extends IntegrationTestCase { - public function setUp() - { - parent::setUp(); - } - - /** - * Tests the generated JS code - * @group Core - */ - public function testJavascriptTrackingCode_withAllOptions() - { - $jsTag = Piwik::getJavascriptCode($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, - $visitorCustomVariables = array( array("name", "value"), array("name 2", "value 2") ), - $pageCustomVariables = array( array("page cvar", "page cvar value") ), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true); - - $expected = "<!-- Piwik --> -<script type="text/javascript"> - var _paq = _paq || []; - _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); - // you can set up to 5 custom variables for each visitor - _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); - _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); - // you can set up to 5 custom variables for each action (page view, download, click, site search) - _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); - _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); - _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); - _paq.push([\"setDoNotTrack\", true]); - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="//localhost/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.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); - })(); -</script> -<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> -<!-- End Piwik Code --> -"; - - $this->assertEquals($expected, $jsTag); - } - - /** - * Tests the generated JS code with protocol overwrite - * @group Core - */ - public function testJavascriptTrackingCode_withAllOptionsAndProtocolOverwrite() - { - Piwik::addAction('Piwik.getJavascriptCode', function (&$codeImpl) { - $codeImpl['protocol'] = 'https://'; - }); - - $jsTag = Piwik::getJavascriptCode($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, - $visitorCustomVariables = array( array("name", "value"), array("name 2", "value 2") ), - $pageCustomVariables = array( array("page cvar", "page cvar value") ), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true); - - $expected = "<!-- Piwik --> -<script type="text/javascript"> - var _paq = _paq || []; - _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); - // you can set up to 5 custom variables for each visitor - _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); - _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); - // you can set up to 5 custom variables for each action (page view, download, click, site search) - _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); - _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); - _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); - _paq.push([\"setDoNotTrack\", true]); - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="https://localhost/piwik/"; - _paq.push(['setTrackerUrl', u+'piwik.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); - })(); -</script> -<noscript><p><img src="https://localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> -<!-- End Piwik Code --> -"; - - $this->assertEquals($expected, $jsTag); - } - - /** - * Tests the generated JS code with options before tracker url - * @group Core - */ - public function testJavascriptTrackingCode_withAllOptionsAndOptionsBeforeTrackerUrl() - { - Piwik::addAction('Piwik.getJavascriptCode', function (&$codeImpl) { - $codeImpl['optionsBeforeTrackerUrl'] .= "_paq.push(['setAPIUrl', 'http://localhost/statistics']);\n "; - }); - - $jsTag = Piwik::getJavascriptCode($idSite = 1, $piwikUrl = 'http://localhost/piwik', - $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, - $visitorCustomVariables = array( array("name", "value"), array("name 2", "value 2") ), - $pageCustomVariables = array( array("page cvar", "page cvar value") ), - $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", - $doNotTrack = true); - - $expected = "<!-- Piwik --> -<script type="text/javascript"> - var _paq = _paq || []; - _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); - // you can set up to 5 custom variables for each visitor - _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); - _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); - // you can set up to 5 custom variables for each action (page view, download, click, site search) - _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); - _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); - _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); - _paq.push([\"setDoNotTrack\", true]); - _paq.push(['trackPageView']); - _paq.push(['enableLinkTracking']); - (function() { - var u="//localhost/piwik/"; - _paq.push(['setAPIUrl', 'http://localhost/statistics']); - _paq.push(['setTrackerUrl', u+'piwik.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); - })(); -</script> -<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> -<!-- End Piwik Code --> -"; - - $this->assertEquals($expected, $jsTag); - } - /** * Dataprovider for testIsNumericValid */ diff --git a/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php new file mode 100644 index 0000000000..343aa97d12 --- /dev/null +++ b/tests/PHPUnit/Integration/Tracker/TrackerCodeGeneratorTest.php @@ -0,0 +1,154 @@ +<?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\Integration\Tracker; + +use Piwik\Piwik; +use Piwik\Tests\Framework\TestCase\IntegrationTestCase; +use Piwik\Tracker\TrackerCodeGenerator; + +/** + * @group Core + */ +class TrackerCodeGeneratorTest extends IntegrationTestCase +{ + public function testJavascriptTrackingCode_withAllOptions() + { + $generator = new TrackerCodeGenerator(); + + $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), + $pageCustomVariables = array(array("page cvar", "page cvar value")), + $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true); + + $expected = "<!-- Piwik --> +<script type="text/javascript"> + var _paq = _paq || []; + _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); + // you can set up to 5 custom variables for each visitor + _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); + _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); + // you can set up to 5 custom variables for each action (page view, download, click, site search) + _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); + _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); + _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); + _paq.push([\"setDoNotTrack\", true]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//localhost/piwik/"; + _paq.push(['setTrackerUrl', u+'piwik.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); + })(); +</script> +<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> +<!-- End Piwik Code --> +"; + + $this->assertEquals($expected, $jsTag); + } + + /** + * Tests the generated JS code with protocol override + */ + public function testJavascriptTrackingCode_withAllOptionsAndProtocolOverwrite() + { + $generator = new TrackerCodeGenerator(); + + Piwik::addAction('Piwik.getJavascriptCode', function (&$codeImpl) { + $codeImpl['protocol'] = 'https://'; + }); + + $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), + $pageCustomVariables = array(array("page cvar", "page cvar value")), + $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true); + + $expected = "<!-- Piwik --> +<script type="text/javascript"> + var _paq = _paq || []; + _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); + // you can set up to 5 custom variables for each visitor + _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); + _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); + // you can set up to 5 custom variables for each action (page view, download, click, site search) + _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); + _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); + _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); + _paq.push([\"setDoNotTrack\", true]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="https://localhost/piwik/"; + _paq.push(['setTrackerUrl', u+'piwik.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); + })(); +</script> +<noscript><p><img src="https://localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> +<!-- End Piwik Code --> +"; + + $this->assertEquals($expected, $jsTag); + } + + /** + * Tests the generated JS code with options before tracker url + */ + public function testJavascriptTrackingCode_withAllOptionsAndOptionsBeforeTrackerUrl() + { + $generator = new TrackerCodeGenerator(); + + Piwik::addAction('Piwik.getJavascriptCode', function (&$codeImpl) { + $codeImpl['optionsBeforeTrackerUrl'] .= "_paq.push(['setAPIUrl', 'http://localhost/statistics']);\n "; + }); + + $jsTag = $generator->generate($idSite = 1, $piwikUrl = 'http://localhost/piwik', + $mergeSubdomains = true, $groupPageTitlesByDomain = true, $mergeAliasUrls = true, + $visitorCustomVariables = array(array("name", "value"), array("name 2", "value 2")), + $pageCustomVariables = array(array("page cvar", "page cvar value")), + $customCampaignNameQueryParam = "campaignKey", $customCampaignKeywordParam = "keywordKey", + $doNotTrack = true); + + $expected = "<!-- Piwik --> +<script type="text/javascript"> + var _paq = _paq || []; + _paq.push([\"setDocumentTitle\", document.domain + \"/\" + document.title]); + // you can set up to 5 custom variables for each visitor + _paq.push([\"setCustomVariable\", 1, \"name\", \"value\", \"visit\"]); + _paq.push([\"setCustomVariable\", 2, \"name 2\", \"value 2\", \"visit\"]); + // you can set up to 5 custom variables for each action (page view, download, click, site search) + _paq.push([\"setCustomVariable\", 1, \"page cvar\", \"page cvar value\", \"page\"]); + _paq.push([\"setCampaignNameKey\", \"campaignKey\"]); + _paq.push([\"setCampaignKeywordKey\", \"keywordKey\"]); + _paq.push([\"setDoNotTrack\", true]); + _paq.push(['trackPageView']); + _paq.push(['enableLinkTracking']); + (function() { + var u="//localhost/piwik/"; + _paq.push(['setAPIUrl', 'http://localhost/statistics']); + _paq.push(['setTrackerUrl', u+'piwik.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); + })(); +</script> +<noscript><p><img src="//localhost/piwik/piwik.php?idsite=1" style="border:0;" alt="" /></p></noscript> +<!-- End Piwik Code --> +"; + + $this->assertEquals($expected, $jsTag); + } +} diff --git a/tests/PHPUnit/UI b/tests/PHPUnit/UI -Subproject f01cae2231c3af48738f98cd1371c45f32fbc55 +Subproject 993f9ce6bbeb6ad9f0a3ac173114198befa86fc diff --git a/tests/PHPUnit/Unit/CliMulti/ProcessTest.php b/tests/PHPUnit/Unit/CliMulti/ProcessTest.php index 12ec4c98e8..755cd60b61 100644 --- a/tests/PHPUnit/Unit/CliMulti/ProcessTest.php +++ b/tests/PHPUnit/Unit/CliMulti/ProcessTest.php @@ -92,11 +92,6 @@ class ProcessTest extends PHPUnit_Framework_TestCase $this->assertFalse($this->process->hasStarted('')); } - public function test_isSupported() - { - $this->assertTrue(Process::isSupported(), 'This test does not work on windows or if the commands ps and awk are not available'); - } - public function test_getSecondsSinceCreation() { sleep(3); diff --git a/tests/travis/travis.sh b/tests/travis/travis.sh index befa1dd84d..95a22d300d 100755 --- a/tests/travis/travis.sh +++ b/tests/travis/travis.sh @@ -42,7 +42,7 @@ then then if [ -n "$PLUGIN_NAME" ] then - artifacts_folder="protected/ui-tests.master.$PLUGIN_NAME" + artifacts_folder="protected/ui-tests.$TRAVIS_BRANCH.$PLUGIN_NAME" else artifacts_folder="ui-tests.$TRAVIS_BRANCH" fi @@ -58,6 +58,9 @@ then else phantomjs ../lib/screenshot-testing/run-tests.js --store-in-ui-tests-repo --persist-fixture-data --assume-artifacts fi + elif [ "$TEST_SUITE" = "AllTests" ] + then + travis_wait ./../../console tests:run --options="--colors" else if [ -n "$PLUGIN_NAME" ] then @@ -67,11 +70,7 @@ then fi fi else - if [ "$COVERAGE" = "System" ] - then - echo "Executing non System tests in test suite SystemTests..." - phpunit --configuration phpunit.xml --testsuite SystemTests --exclude-group System --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-system.xml || true - elif [ "$COVERAGE" = "Unit" ] + if [ "$COVERAGE" = "Unit" ] then echo "Executing tests in test suite UnitTests..." phpunit --configuration phpunit.xml --testsuite UnitTests --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-unit.xml || true @@ -80,4 +79,4 @@ else echo "Executing tests in test suite IntegrationTests..." phpunit --configuration phpunit.xml --testsuite IntegrationTests --colors --coverage-clover $TRAVIS_BUILD_DIR/build/logs/clover-integration.xml || true fi; -fi
\ No newline at end of file +fi |