Skip to content
GitLab
Explorer
Connexion
S'inscrire
Navigation principale
Rechercher ou aller à…
Projet
S
stats-facil
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de paquets
Registre de conteneur
Registre de modèles
Opération
Environnements
Modules Terraform
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
facil
stats-facil
Validations
064f14ca
Valider
064f14ca
rédigé
11 years ago
par
Benaka Moorthi
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Fixing Core/Tracker/VisitTest test.
parent
8d1adbc7
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
core/Tracker/VisitExcluded.php
+10
-2
10 ajouts, 2 suppressions
core/Tracker/VisitExcluded.php
tests/PHPUnit/Core/Tracker/VisitTest.php
+11
-7
11 ajouts, 7 suppressions
tests/PHPUnit/Core/Tracker/VisitTest.php
avec
21 ajouts
et
9 suppressions
core/Tracker/VisitExcluded.php
+
10
−
2
Voir le fichier @
064f14ca
...
@@ -14,11 +14,19 @@
...
@@ -14,11 +14,19 @@
*/
*/
class
Piwik_Tracker_VisitExcluded
class
Piwik_Tracker_VisitExcluded
{
{
public
function
__construct
(
Piwik_Tracker_Request
$request
,
$ip
)
public
function
__construct
(
Piwik_Tracker_Request
$request
,
$ip
=
false
,
$userAgent
=
false
)
{
{
if
(
$ip
===
false
)
{
$ip
=
$request
->
getIp
();
}
if
(
$userAgent
===
false
)
{
$userAgent
=
$request
->
getUserAgent
();
}
$this
->
request
=
$request
;
$this
->
request
=
$request
;
$this
->
idSite
=
$request
->
getIdSite
();
$this
->
idSite
=
$request
->
getIdSite
();
$this
->
userAgent
=
$
request
->
getU
serAgent
()
;
$this
->
userAgent
=
$
u
serAgent
;
$this
->
ip
=
$ip
;
$this
->
ip
=
$ip
;
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
tests/PHPUnit/Core/Tracker/VisitTest.php
+
11
−
7
Voir le fichier @
064f14ca
...
@@ -69,15 +69,17 @@ class Tracker_VisitTest extends DatabaseTestCase
...
@@ -69,15 +69,17 @@ class Tracker_VisitTest extends DatabaseTestCase
*/
*/
public
function
testIsVisitorIpExcluded
(
$excludedIp
,
$tests
)
public
function
testIsVisitorIpExcluded
(
$excludedIp
,
$tests
)
{
{
$visit
=
new
Test_Piwik_TrackerVisit_public
();
$idsite
=
Piwik_SitesManager_API
::
getInstance
()
->
addSite
(
"name"
,
"http://piwik.net/"
,
$ecommerce
=
0
,
$idsite
=
Piwik_SitesManager_API
::
getInstance
()
->
addSite
(
"name"
,
"http://piwik.net/"
,
$ecommerce
=
0
,
$siteSearch
=
1
,
$searchKeywordParameters
=
null
,
$searchCategoryParameters
=
null
,
$excludedIp
);
$siteSearch
=
1
,
$searchKeywordParameters
=
null
,
$searchCategoryParameters
=
null
,
$excludedIp
);
$visit
->
setRequest
(
array
(
'idsite'
=>
$idsite
));
$request
=
new
Piwik_Tracker_Request
(
array
(
'idsite'
=>
$idsite
));
// test that IPs within the range, or the given IP, are excluded
// test that IPs within the range, or the given IP, are excluded
foreach
(
$tests
as
$ip
=>
$expected
)
{
foreach
(
$tests
as
$ip
=>
$expected
)
{
$testIpIsExcluded
=
Piwik_IP
::
P2N
(
$ip
);
$testIpIsExcluded
=
Piwik_IP
::
P2N
(
$ip
);
$this
->
assertSame
(
$expected
,
$visit
->
public_isVisitorIpExcluded
(
$testIpIsExcluded
));
$excluded
=
new
Test_Piwik_Tracker_VisitExcluded_public
(
$request
,
$testIpIsExcluded
);
$this
->
assertSame
(
$expected
,
$excluded
->
public_isVisitorIpExcluded
(
$testIpIsExcluded
));
}
}
}
}
...
@@ -116,21 +118,23 @@ class Tracker_VisitTest extends DatabaseTestCase
...
@@ -116,21 +118,23 @@ class Tracker_VisitTest extends DatabaseTestCase
{
{
Piwik_SitesManager_API
::
getInstance
()
->
setSiteSpecificUserAgentExcludeEnabled
(
true
);
Piwik_SitesManager_API
::
getInstance
()
->
setSiteSpecificUserAgentExcludeEnabled
(
true
);
$visit
=
new
Test_Piwik_TrackerVisit_public
();
$idsite
=
Piwik_SitesManager_API
::
getInstance
()
->
addSite
(
"name"
,
"http://piwik.net/"
,
$ecommerce
=
0
,
$idsite
=
Piwik_SitesManager_API
::
getInstance
()
->
addSite
(
"name"
,
"http://piwik.net/"
,
$ecommerce
=
0
,
$siteSearch
=
1
,
$searchKeywordParameters
=
null
,
$searchCategoryParameters
=
null
,
$excludedIp
=
null
,
$siteSearch
=
1
,
$searchKeywordParameters
=
null
,
$searchCategoryParameters
=
null
,
$excludedIp
=
null
,
$excludedQueryParameters
=
null
,
$timezone
=
null
,
$currency
=
null
,
$group
=
null
,
$startDate
=
null
,
$excludedQueryParameters
=
null
,
$timezone
=
null
,
$currency
=
null
,
$group
=
null
,
$startDate
=
null
,
$excludedUserAgent
);
$excludedUserAgent
);
$visit
->
setRequest
(
array
(
'idsite'
=>
$idsite
));
$request
=
new
Piwik_Tracker_Request
(
array
(
'idsite'
=>
$idsite
));
// test that user agents that contain excluded user agent strings are excluded
// test that user agents that contain excluded user agent strings are excluded
foreach
(
$tests
as
$ua
=>
$expected
)
{
foreach
(
$tests
as
$ua
=>
$expected
)
{
$this
->
assertSame
(
$expected
,
$visit
->
public_isUserAgentExcluded
(
$ua
),
"Result if isUserAgentExcluded('
$ua
') was not "
.
(
$expected
?
'true'
:
'false'
)
.
"."
);
$excluded
=
new
Test_Piwik_Tracker_VisitExcluded_public
(
$request
,
$ip
=
false
,
$ua
);
$this
->
assertSame
(
$expected
,
$excluded
->
public_isUserAgentExcluded
(
$ua
),
"Result if isUserAgentExcluded('
$ua
') was not "
.
(
$expected
?
'true'
:
'false'
)
.
"."
);
}
}
}
}
}
}
class
Test_Piwik_TrackerVisit_public
extends
Piwik_Tracker_Visit
class
Test_Piwik_Tracker
_
Visit
Excluded
_public
extends
Piwik_Tracker_Visit
Excluded
{
{
public
function
public_isVisitorIpExcluded
(
$ip
)
public
function
public_isVisitorIpExcluded
(
$ip
)
{
{
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter