예제 #1
0
 function test_extractUrlAndActionNameFromRequest()
 {
     $userFile = PIWIK_PATH_TEST_TO_ROOT . '/tests/resources/Tracker/Action.config.ini.php';
     $config = Piwik_Tracker_Config::getInstance();
     $config->init($userFile);
     $action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest();
     $tests = array(array('request' => array('link' => 'http://example.org'), 'expected' => array('name' => 'http://example.org', 'url' => 'http://example.org', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('link' => '	http://example.org/Category/Test/  	'), 'expected' => array('name' => 'http://example.org/Category/Test/', 'url' => 'http://example.org/Category/Test/', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('download' => 'http://example.org/*$test.zip'), 'expected' => array('name' => 'http://example.org/*$test.zip', 'url' => 'http://example.org/*$test.zip', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD)), array('request' => array('download' => 'http://example.org/CATEGORY/test///test.pdf'), 'expected' => array('name' => 'http://example.org/CATEGORY/test///test.pdf', 'url' => 'http://example.org/CATEGORY/test///test.pdf', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD)), array('request' => array('url' => 'http://example.org/'), 'expected' => array('name' => 'index', 'url' => 'http://example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION)), array('request' => array('url' => 'http://example.org/CATEGORY/'), 'expected' => array('name' => 'CATEGORY/index', 'url' => 'http://example.org/CATEGORY/', 'type' => Piwik_Tracker_Action::TYPE_ACTION)), array('request' => array('url' => 'http://example.org/category/', 'action_name' => 'custom name with/one delimiter/two delimiters/'), 'expected' => array('name' => 'custom name with/one delimiter/two delimiters', 'url' => 'http://example.org/category/', 'type' => Piwik_Tracker_Action::TYPE_ACTION)), array('request' => array('url' => 'http://example.org/category/', 'action_name' => 'http://custom action name look like url/'), 'expected' => array('name' => 'http:/custom action name look like url', 'url' => 'http://example.org/category/', 'type' => Piwik_Tracker_Action::TYPE_ACTION)), array('request' => array('url' => "http://example.org/category/test///test  wOw  \t"), 'expected' => array('name' => 'category/test/test  wOw', 'url' => 'http://example.org/category/test///test  wOw', 'type' => Piwik_Tracker_Action::TYPE_ACTION)), array('request' => array('url' => "http://example.org/category/1/0/t/test"), 'expected' => array('name' => 'category/1/0/t/test', 'url' => 'http://example.org/category/1/0/t/test', 'type' => Piwik_Tracker_Action::TYPE_ACTION)));
     foreach ($tests as $test) {
         $request = $test['request'];
         $expected = $test['expected'];
         $action->setRequest($request);
         $this->assertEqual($action->public_extractUrlAndActionNameFromRequest(), $expected);
     }
 }
예제 #2
0
 /**
  * @dataProvider getExtractUrlData
  * @group Core
  * @group Tracker
  * @group Tracker_Action
  */
 public function testExtractUrlAndActionNameFromRequest($request, $expected)
 {
     $action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest();
     $action->setRequest($request);
     $this->assertEquals($action->public_extractUrlAndActionNameFromRequest(), $expected);
 }
예제 #3
0
 /**
  * @dataProvider getExtractUrlData
  * @group Core
  * @group Tracker
  * @group Tracker_Action
  */
 public function testExtractUrlAndActionNameFromRequest($request, $expected)
 {
     $this->setUpRootAccess();
     $idSite = Piwik_SitesManager_API::getInstance()->addSite("site1", array('http://example.org'));
     $action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest();
     $action->setRequest($request);
     $action->setIdSite($idSite);
     $this->assertEquals($action->public_extractUrlAndActionNameFromRequest(), $expected);
 }
 function test_extractUrlAndActionNameFromRequest()
 {
     $action = new Test_Piwik_TrackerAction_extractUrlAndActionNameFromRequest();
     $tests = array(array('request' => array('link' => 'http://example.org'), 'expected' => array('name' => null, 'url' => 'http://example.org', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('link' => 'http://example.org', 'action_name' => 'Example.org'), 'expected' => array('name' => 'Example.org', 'url' => 'http://example.org', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('link' => '	http://example.org/Category/Test/  	'), 'expected' => array('name' => null, 'url' => 'http://example.org/Category/Test/', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('link' => '	http://example.org/Category/Test/  	', 'action_name' => '  Example dot org '), 'expected' => array('name' => 'Example dot org', 'url' => 'http://example.org/Category/Test/', 'type' => Piwik_Tracker_Action::TYPE_OUTLINK)), array('request' => array('download' => 'http://example.org/*$test.zip'), 'expected' => array('name' => null, 'url' => 'http://example.org/*$test.zip', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD)), array('request' => array('download' => 'http://example.org/*$test.zip', 'action_name' => 'Download test.zip'), 'expected' => array('name' => 'Download test.zip', 'url' => 'http://example.org/*$test.zip', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD)), array('request' => array('download' => 'http://example.org/CATEGORY/test///test.pdf'), 'expected' => array('name' => null, 'url' => 'http://example.org/CATEGORY/test///test.pdf', 'type' => Piwik_Tracker_Action::TYPE_DOWNLOAD)), array('request' => array('url' => 'http://example.org/'), 'expected' => array('name' => null, 'url' => 'http://example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/', 'action_name' => 'Example.org Website'), 'expected' => array('name' => 'Example.org Website', 'url' => 'http://example.org/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/CATEGORY/'), 'expected' => array('name' => null, 'url' => 'http://example.org/CATEGORY/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/CATEGORY/TEST', 'action_name' => 'Example.org / Category / test /'), 'expected' => array('name' => 'Example.org/Category/test', 'url' => 'http://example.org/CATEGORY/TEST', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/?2,123'), 'expected' => array('name' => null, 'url' => 'http://example.org/?2,123', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array(), 'expected' => array('name' => null, 'url' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('name' => null, 'url' => "\n"), 'expected' => array('name' => null, 'url' => '', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/category/', 'action_name' => 'custom name with/one delimiter/two delimiters/'), 'expected' => array('name' => 'custom name with/one delimiter/two delimiters', 'url' => 'http://example.org/category/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/category/', 'action_name' => 'http://custom action name look like url/'), 'expected' => array('name' => 'http:/custom action name look like url', 'url' => 'http://example.org/category/', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => "http://example.org/category/test///test  wOw  \t"), 'expected' => array('name' => null, 'url' => 'http://example.org/category/test///test  wOw', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => "http://example.org/category/1/0/t/test"), 'expected' => array('name' => null, 'url' => 'http://example.org/category/1/0/t/test', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/ACTION/URL', 'action_name' => "Test …"), 'expected' => array('name' => 'Test …', 'url' => 'http://example.org/ACTION/URL', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/ACTION/URL', 'action_name' => "Special & chars"), 'expected' => array('name' => 'Special & chars', 'url' => 'http://example.org/ACTION/URL', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/ACTION/URL', 'action_name' => "Tést"), 'expected' => array('name' => 'Tést', 'url' => 'http://example.org/ACTION/URL', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/ACTION/URL', 'action_name' => "Tést"), 'expected' => array('name' => 'Tést', 'url' => 'http://example.org/ACTION/URL', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)), array('request' => array('url' => 'http://example.org/ACTION/URL', 'action_name' => "Tést"), 'expected' => array('name' => version_compare(PHP_VERSION, '5.2.5') === -1 ? 'T\\xe9st' : 'Tést', 'url' => 'http://example.org/ACTION/URL', 'type' => Piwik_Tracker_Action::TYPE_ACTION_URL)));
     foreach ($tests as $test) {
         $request = $test['request'];
         $expected = $test['expected'];
         $action->setRequest($request);
         $this->assertEqual($action->public_extractUrlAndActionNameFromRequest(), $expected);
     }
 }