diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-10-05 15:05:47 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-10-05 15:05:47 +0400 |
commit | 5a1eab97f54b44f57356b4276b9c9df2a8eef51b (patch) | |
tree | 83864ece2806ccf6e6bb49abf3fd65de92c13ad8 /tests/PHPUnit/System/UrlNormalizationTest.php | |
parent | 19bcd2d262343eae9d553378e4c66ce7e033b4d8 (diff) |
refs #5940 put tests in correct folders, better testsuite names, some tests still fail and I cannot figure out why
Diffstat (limited to 'tests/PHPUnit/System/UrlNormalizationTest.php')
-rw-r--r-- | tests/PHPUnit/System/UrlNormalizationTest.php | 123 |
1 files changed, 123 insertions, 0 deletions
diff --git a/tests/PHPUnit/System/UrlNormalizationTest.php b/tests/PHPUnit/System/UrlNormalizationTest.php new file mode 100644 index 0000000000..07011200ee --- /dev/null +++ b/tests/PHPUnit/System/UrlNormalizationTest.php @@ -0,0 +1,123 @@ +<?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\System; + +use Piwik\Common; +use Piwik\Db; +use Piwik\Tracker\Action; +use Piwik\Tests\SystemTestCase; +use Piwik\Tests\Fixtures\OneVisitWithAbnormalPageviewUrls; + +/** + * Tests the URL normalization. + * + * @group Core + * @group UrlNormalizationTest + */ +class UrlNormalizationTest extends SystemTestCase +{ + public static $fixture = null; // initialized below class definition + + /** + * @dataProvider getApiForTesting + */ + public function testApi($api, $params) + { + $this->runApiTests($api, $params); + } + + public function getApiForTesting() + { + $idSite = self::$fixture->idSite; + $dateTime = self::$fixture->dateTime; + + $return = array(); + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_urls', + 'idSite' => $idSite, + 'date' => $dateTime, + )); + $return[] = array('Actions.getPageTitles', array( + 'testSuffix' => '_titles', + 'idSite' => $idSite, + 'date' => $dateTime, + )); + + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_pagesSegmented', + 'idSite' => $idSite, + 'date' => $dateTime, + 'segment' => 'pageUrl==https://WWw.example.org/foo/bar2.html', + )); + // Testing entryPageUrl with AND segment + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_pagesSegmented', + 'idSite' => $idSite, + 'date' => $dateTime, + 'segment' => 'entryPageUrl==http://example.org/foo/bar.html;pageUrl==https://WWw.example.org/foo/bar2.html', + )); + // Testing exitPageUrl with AND segment + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_pagesSegmented', + 'idSite' => $idSite, + 'date' => $dateTime, + 'segment' => 'exitPageUrl==example.org/foo/bar4.html;pageUrl==https://WWw.example.org/foo/bar2.html', + )); + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_pagesSegmented', + 'idSite' => $idSite, + 'date' => $dateTime, + 'segment' => 'pageUrl==example.org/foo/bar2.html', + )); + $return[] = array('Actions.getPageUrls', array( + 'testSuffix' => '_pagesSegmentedRef', + 'idSite' => $idSite, + 'date' => $dateTime, + 'segment' => 'referrerUrl==http://www.google.com/search?q=piwik', + )); + $return[] = array('Referrers.getKeywordsForPageUrl', array( + 'testSuffix' => '_keywords', + 'idSite' => $idSite, + 'date' => $dateTime, + 'otherRequestParameters' => array( + 'url' => 'http://WWW.example.org/foo/bar.html' + ) + )); + return $return; + } + + /** + * @depends testApi + */ + public function testCheckPostConditions() + { + $sql = "SELECT count(*) FROM " . Common::prefixTable('log_action'); + $count = Db::get()->fetchOne($sql); + $expected = 9; // 4 urls + 5 titles + $this->assertEquals($expected, $count, "only $expected actions expected"); + + $sql = "SELECT name, url_prefix FROM " . Common::prefixTable('log_action') + . " WHERE type = " . Action::TYPE_PAGE_URL + . " ORDER BY idaction ASC"; + $urls = Db::get()->fetchAll($sql); + $expected = array( + array('name' => 'example.org/foo/bar.html', 'url_prefix' => 0), + array('name' => 'example.org/foo/bar2.html', 'url_prefix' => 3), + array('name' => 'example.org/foo/bar3.html', 'url_prefix' => 1), + array('name' => 'example.org/foo/bar4.html', 'url_prefix' => 2) + ); + $this->assertEquals($expected, $urls, "normalization went wrong"); + } + + public static function getOutputPrefix() + { + return 'UrlNormalization'; + } +} + +UrlNormalizationTest::$fixture = new OneVisitWithAbnormalPageviewUrls();
\ No newline at end of file |