diff options
Diffstat (limited to 'plugins/Referrers/tests/Unit/DataTable/Filter/UrlsFromWebsiteIdTest.php')
-rw-r--r-- | plugins/Referrers/tests/Unit/DataTable/Filter/UrlsFromWebsiteIdTest.php | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/plugins/Referrers/tests/Unit/DataTable/Filter/UrlsFromWebsiteIdTest.php b/plugins/Referrers/tests/Unit/DataTable/Filter/UrlsFromWebsiteIdTest.php new file mode 100644 index 0000000000..47590690e2 --- /dev/null +++ b/plugins/Referrers/tests/Unit/DataTable/Filter/UrlsFromWebsiteIdTest.php @@ -0,0 +1,48 @@ +<?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\Plugins\Referrers\tests\Unit\DataTable\Filter; + +use Piwik\DataTable; +use Piwik\Plugins\Referrers\DataTable\Filter\UrlsFromWebsiteId; + +require_once PIWIK_INCLUDE_PATH . '/plugins/Referrers/functions.php'; + +class UrlsFromWebsiteIdTest extends \PHPUnit_Framework_TestCase +{ + public function test_filter_ignoresDomainsPortssAndPortsInRecord() + { + $table = new DataTable(); + $table->addRowsFromSimpleArray([ + ['label' => 'https://abc.com/x/y/z', 'nb_visits' => 1], + ['label' => 'https://def.com/x/y/z', 'nb_visits' => 1], + ['label' => 'https://def.com/x/y/z/', 'nb_visits' => 1], + ['label' => 'http://abc.com:3000/x/y/z', 'nb_visits' => 1], + ['label' => 'http://abc.com/', 'nb_visits' => 1], + ]); + + $filter = new UrlsFromWebsiteId($table); + $filter->filter($table); + + $expected = [ + new DataTable\Row([ + DataTable\Row::COLUMNS => ['label' => 'x/y/z', 'nb_visits' => 3], + DataTable\Row::METADATA => ['url' => ''], + ]), + new DataTable\Row([ + DataTable\Row::COLUMNS => ['label' => 'x/y/z/', 'nb_visits' => 1], + DataTable\Row::METADATA => ['url' => ''], + ]), + new DataTable\Row([ + DataTable\Row::COLUMNS => ['label' => 'index', 'nb_visits' => 1], + DataTable\Row::METADATA => ['url' => ''], + ]), + ]; + $this->assertEquals($expected, array_values($table->getRows())); + } +}
\ No newline at end of file |