public function GoogleAnalyticsCustomDimensionsAndMetricsTest::testGoogleAnalyticsCustomDimensionsTokenFormValidation in Google Analytics 8.2
Same name and namespace in other branches
- 8.3 tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php \Drupal\Tests\google_analytics\Functional\GoogleAnalyticsCustomDimensionsAndMetricsTest::testGoogleAnalyticsCustomDimensionsTokenFormValidation()
- 4.x tests/src/Functional/GoogleAnalyticsCustomDimensionsAndMetricsTest.php \Drupal\Tests\google_analytics\Functional\GoogleAnalyticsCustomDimensionsAndMetricsTest::testGoogleAnalyticsCustomDimensionsTokenFormValidation()
Tests if Custom Dimensions token form validation works.
File
- tests/
src/ Functional/ GoogleAnalyticsCustomDimensionsAndMetricsTest.php, line 221
Class
- GoogleAnalyticsCustomDimensionsAndMetricsTest
- Test custom dimensions and metrics functionality of Google Analytics module.
Namespace
Drupal\Tests\google_analytics\FunctionalCode
public function testGoogleAnalyticsCustomDimensionsTokenFormValidation() {
$ua_code = 'UA-123456-1';
// Check form validation.
$edit['google_analytics_account'] = $ua_code;
$edit['google_analytics_custom_dimension[indexes][1][value]'] = '[current-user:name]';
$edit['google_analytics_custom_dimension[indexes][2][value]'] = '[current-user:edit-url]';
$edit['google_analytics_custom_dimension[indexes][3][value]'] = '[user:name]';
$edit['google_analytics_custom_dimension[indexes][4][value]'] = '[term:name]';
$edit['google_analytics_custom_dimension[indexes][5][value]'] = '[term:tid]';
$this
->drupalPostForm('admin/config/system/google-analytics', $edit, t('Save configuration'));
$this
->assertSession()
->responseContains(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', [
'%element-title' => t('Custom dimension value #@index', [
'@index' => 1,
]),
'@invalid-tokens' => implode(', ', [
'[current-user:name]',
]),
]));
$this
->assertSession()
->responseContains(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', [
'%element-title' => t('Custom dimension value #@index', [
'@index' => 2,
]),
'@invalid-tokens' => implode(', ', [
'[current-user:edit-url]',
]),
]));
$this
->assertSession()
->responseContains(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', [
'%element-title' => t('Custom dimension value #@index', [
'@index' => 3,
]),
'@invalid-tokens' => implode(', ', [
'[user:name]',
]),
]));
// BUG #2037595
//$this->assertSession()->responseNotContains(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', ['%element-title' => t('Custom dimension value #@index', ['@index' => 4]), '@invalid-tokens' => implode(', ', ['[term:name]'])]));
//$this->assertSession()->responseNotContains(t('The %element-title is using the following forbidden tokens with personal identifying information: @invalid-tokens.', ['%element-title' => t('Custom dimension value #@index', ['@index' => 5]), '@invalid-tokens' => implode(', ', ['[term:tid]'])]));
}