diff options
author | diosmosis <benaka@piwik.pro> | 2015-05-25 00:23:36 +0300 |
---|---|---|
committer | diosmosis <benaka@piwik.pro> | 2015-05-25 01:08:33 +0300 |
commit | 864328c0ec6ba69b33efc654229b9c825ada9589 (patch) | |
tree | e0162a26d3b301a7f476a79a482abbfab884f40a /plugins/PrivacyManager | |
parent | bf85dab4935e942202afc307463d3f8dfe3d2891 (diff) |
Add unit test for the new DimensionMetadataProvider class.
Diffstat (limited to 'plugins/PrivacyManager')
-rw-r--r-- | plugins/PrivacyManager/tests/Unit/DimensionMetadataProviderTest.php | 124 |
1 files changed, 124 insertions, 0 deletions
diff --git a/plugins/PrivacyManager/tests/Unit/DimensionMetadataProviderTest.php b/plugins/PrivacyManager/tests/Unit/DimensionMetadataProviderTest.php new file mode 100644 index 0000000000..7c015a9206 --- /dev/null +++ b/plugins/PrivacyManager/tests/Unit/DimensionMetadataProviderTest.php @@ -0,0 +1,124 @@ +<?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\PrivacyManager\tests\Unit; + +use Piwik\Plugins\PrivacyManager\DimensionMetadataProvider; +use Piwik\Tests\Framework\TestCase\UnitTestCase; +use Piwik\Plugin\Manager as PluginManager; + +class DimensionMetadataProviderTest extends UnitTestCase +{ + public function setUp() + { + parent::setUp(); + + /** @var PluginManager $manager */ + $manager = $this->environment->getContainer()->get('Piwik\Plugin\Manager'); + $manager->loadPlugins(array('Events', 'Contents')); + } + + public function test_getActionReferenceColumnsByTable_DetectsActionReferenceDimensions_AndIncludesHardocdedColumns() + { + $dimensionMetadataProvider = new DimensionMetadataProvider(); + + $actualColumns = $dimensionMetadataProvider->getActionReferenceColumnsByTable(); + + $expectedColumns = array( + 'log_link_visit_action' => array( + 'idaction_url', + 'idaction_url_ref', + 'idaction_name_ref', + 'idaction_event_action', + 'idaction_event_category', + 'idaction_name', + 'idaction_content_interaction', + 'idaction_content_name', + 'idaction_content_piece', + 'idaction_content_target' + ), + 'log_conversion' => array( + 'idaction_url', + ), + 'log_visit' => array( + 'visit_exit_idaction_url', + 'visit_exit_idaction_name', + 'visit_entry_idaction_url', + 'visit_entry_idaction_name', + ), + 'log_conversion_item' => array( + 'idaction_sku', + 'idaction_name', + 'idaction_category', + 'idaction_category2', + 'idaction_category3', + 'idaction_category4', + 'idaction_category5', + ), + ); + + $this->assertEquals($expectedColumns, $actualColumns); + } + + public function test_getActionReferenceColumnsByTable_AppliesOverrideColumnsCorrectly_WithoutAllowingDuplicates() + { + $dimensionMetadataProvider = new DimensionMetadataProvider(array( + 'log_link_visit_action' => array('idaction_url', + 'idaction_event_category' + ), + + 'log_conversion' => array(), + + 'log_conversion_item' => array('some_unknown_idaction_column'), + + 'log_custom_table' => array('some_column1', 'some_column2') + )); + + $actualColumns = $dimensionMetadataProvider->getActionReferenceColumnsByTable(); + + $expectedColumns = array( + 'log_link_visit_action' => array( + 'idaction_url', + 'idaction_url_ref', + 'idaction_name_ref', + 'idaction_event_action', + 'idaction_event_category', + 'idaction_name', + 'idaction_content_interaction', + 'idaction_content_name', + 'idaction_content_piece', + 'idaction_content_target' + ), + 'log_conversion' => array( + 'idaction_url', + ), + 'log_visit' => array( + 'visit_exit_idaction_url', + 'visit_exit_idaction_name', + 'visit_entry_idaction_url', + 'visit_entry_idaction_name', + ), + 'log_conversion_item' => array( + 'idaction_sku', + 'idaction_name', + 'idaction_category', + 'idaction_category2', + 'idaction_category3', + 'idaction_category4', + 'idaction_category5', + 'some_unknown_idaction_column' + ), + 'log_custom_table' => array( + 'some_column1', + 'some_column2' + ) + ); + + $this->assertEquals($expectedColumns, $actualColumns); + } +}
\ No newline at end of file |