Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
UTMaltor
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Extensions
UTMaltor
Commits
8eb65f44
Unverified
Commit
8eb65f44
authored
2 weeks ago
by
JonGold
Browse files
Options
Downloads
Patches
Plain Diff
initial work on test fixing
parent
2fb651b1
Branches
main
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
CRM/Utmaltor/Logic/Alter.php
+5
-1
5 additions, 1 deletion
CRM/Utmaltor/Logic/Alter.php
tests/phpunit/CRM/Utmaltor/AlterTest.php
+10
-1
10 additions, 1 deletion
tests/phpunit/CRM/Utmaltor/AlterTest.php
utmaltor.php
+1
-1
1 addition, 1 deletion
utmaltor.php
with
16 additions
and
3 deletions
CRM/Utmaltor/Logic/Alter.php
+
5
−
1
View file @
8eb65f44
...
...
@@ -8,8 +8,12 @@ class CRM_Utmaltor_Logic_Alter {
$this
->
smarty
=
CRM_Utmaltor_Logic_Smarty
::
singleton
(
$params
);
}
public
function
url
(
$urlMatches
)
{
public
function
url
FindReplace
(
$urlMatches
)
{
$url
=
$urlMatches
[
1
];
$this
->
url
(
$url
);
}
public
function
url
(
$url
)
{
$url
=
$this
->
fixUrl
(
$url
);
$url
=
$this
->
alterSource
(
$url
,
$this
->
smarty
);
$url
=
$this
->
alterMedium
(
$url
,
$this
->
smarty
);
...
...
This diff is collapsed.
Click to expand it.
tests/phpunit/CRM/Utmaltor/AlterTest.php
+
10
−
1
View file @
8eb65f44
...
...
@@ -15,6 +15,14 @@ require_once 'BaseTest.php';
class
CRM_Utmaltor_AlterTest
extends
CRM_Utmaltor_BaseTest
{
public
function
testAlterCleanUrl
()
{
$this
->
campaign
=
200
;
$this
->
medium
=
'email'
;
$this
->
source
=
'sourceTest'
;
$params
=
[
'campaign'
=>
$this
->
campaign
,
'medium'
=>
$this
->
medium
,
'source'
=>
$this
->
source
,
];
$url
=
'https://www.wemove.eu/test'
;
$expectedUrl
=
implode
(
''
,
[
'https://www.wemove.eu/test?utm_source='
,
...
...
@@ -24,7 +32,8 @@ class CRM_Utmaltor_AlterTest extends CRM_Utmaltor_BaseTest {
'&utm_campaign='
,
$this
->
utmSmarty
->
parse
(
$this
->
campaign
),
]);
$actualUrl
=
\CRM_Utmaltor_Logic_Alter
::
url
(
$url
,
$this
->
utmSmarty
);
$alter
=
new
\CRM_Utmaltor_Logic_Alter
(
$params
);
$actualUrl
=
$alter
->
url
(
$url
);
$this
->
assertEquals
(
$expectedUrl
,
$actualUrl
);
}
...
...
This diff is collapsed.
Click to expand it.
utmaltor.php
+
1
−
1
View file @
8eb65f44
...
...
@@ -79,7 +79,7 @@ function _utmaltor_findUrls($text, $params) {
$domains
=
str_replace
(
'.'
,
'\.'
,
$domains
);
$re
=
'/(http[^\s"]+('
.
$domains
.
')[^\s"<]*)/imu'
;
$callback
=
new
CRM_Utmaltor_Logic_Alter
(
$params
);
$text
=
preg_replace_callback
(
$re
,
[
$callback
,
'url'
],
$text
);
$text
=
preg_replace_callback
(
$re
,
[
$callback
,
'url
FindReplace
'
],
$text
);
return
$text
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment