Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
bibliossimo
opacce
Commits
d6f22dc0
Commit
d6f22dc0
authored
Feb 22, 2018
by
Ghislain Loas
Browse files
dev #58111 stopTracking when visiting new features
parent
5e8c4217
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
14 deletions
+27
-14
application/modules/admin/controllers/FeatureController.php
application/modules/admin/controllers/FeatureController.php
+1
-0
library/Class/Feature.php
library/Class/Feature.php
+10
-1
tests/application/modules/admin/controllers/IndexControllerFeaturesTrackingTest.php
...admin/controllers/IndexControllerFeaturesTrackingTest.php
+16
-13
No files found.
application/modules/admin/controllers/FeatureController.php
View file @
d6f22dc0
...
...
@@ -23,6 +23,7 @@
class
Admin_FeatureController
extends
ZendAfi_Controller_Action
{
public
function
indexAction
()
{
$this
->
view
->
titre
=
$this
->
_
(
'Les fonctionnalités du logiciel Bokeh'
);
(
new
Class_Feature
())
->
stopTracking
();
$user
=
Class_Users
::
getIdentity
();
$this
->
view
->
new_features
=
(
new
Class_Feature
)
->
findNewFor
(
$user
);
$this
->
view
->
checked_features
=
(
new
Class_Feature
)
->
findCheckedBy
(
$user
);
...
...
library/Class/Feature.php
View file @
d6f22dc0
...
...
@@ -188,12 +188,21 @@ class Class_Feature {
public
function
stopTracking
()
{
if
(
!
Class_AdminVar
::
get
(
'FEATURES_TRACKING_ENABLE'
))
return
;
if
(
!
$user
=
Class_Users
::
getIdentity
())
return
;
if
(
!
$user
->
isAdmin
())
return
;
$this
->
_getCookieJar
()
->
getKey
();
$this
->
_session
=
new
Zend_Session_Namespace
(
$this
->
_getCookieJar
()
->
getKey
());
return
$this
->
_getCookieJar
()
->
setcookie
(
$this
->
_getCookieJar
()
->
getKey
(),
'1'
,
$this
->
getTimeSource
()
->
time
()
+
(
3600
*
24
*
30
*
6
));
$this
->
getTimeSource
()
->
time
()
+
(
3600
*
24
*
30
*
3
));
}
}
...
...
tests/application/modules/admin/controllers/IndexControllerFeaturesTrackingTest.php
View file @
d6f22dc0
...
...
@@ -39,12 +39,10 @@ abstract class IndexControllerFeaturesTrackingTestCase extends Admin_AbstractCon
Class_Feature
::
setCookieJar
(
$this
->
_cookie_jar
=
$this
->
mock
()
->
whenCalled
(
'setcookie'
)
->
answers
(
null
)
->
answers
(
true
)
->
whenCalled
(
'getKey'
)
->
answers
(
'tracking_features_7_11_20'
)
->
beStrict
());
->
answers
(
'tracking_features_7_11_20'
));
}
...
...
@@ -128,10 +126,15 @@ class IndexControllerFeaturesTrackingExistingCookieVisitTest
extends
IndexControllerFeaturesTrackingTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
$_COOKIE
[
'tracking_features_7_11_20'
]
=
1
;
$this
->
dispatch
(
'/'
,
true
);
}
/** @test */
public
function
shouldNotDisplayNewFeaturesMessage
()
{
$_COOKIE
[
'tracking_features_'
.
BOKEH_RELEASE_NUMBER
]
=
1
;
$this
->
dispatch
(
'/'
,
true
);
$this
->
assertNotXPathContentContains
(
'//script'
,
$this
->
_expected_message
);
}
}
...
...
@@ -148,24 +151,24 @@ class IndexControllerFeaturesTrackingUntrackTest
->
whenCalled
(
'setcookie'
)
->
with
(
'tracking_features_7_11_20'
,
1
,
15
34762
314
)
->
answers
(
$_COOKIE
=
[
'tracking_features_7_11_20'
=>
1
]
)
15
26986
314
)
->
answers
(
true
)
->
whenCalled
(
'getKey'
)
->
answers
(
'tracking_features_7_11_20'
));
$this
->
dispatch
(
'/admin/feature/stop-tracking'
,
true
);
}
/** @test */
public
function
shouldNotDisplayNewFeaturesMessage
()
{
$this
->
assertEquals
(
1
,
$_COOKIE
[
'tracking_features_7_11_20'
]);
public
function
stopTrackingActionshouldSetCookie
()
{
$this
->
dispatch
(
'/admin/feature/stop-tracking'
,
true
);
$this
->
assertTrue
(
$this
->
_cookie_jar
->
methodHasBeenCalled
(
'setcookie'
));
}
/** @test */
public
function
shouldSetCookie
()
{
public
function
indexActionSetCookie
()
{
$this
->
dispatch
(
'/admin/feature/index'
,
true
);
$this
->
assertTrue
(
$this
->
_cookie_jar
->
methodHasBeenCalled
(
'setcookie'
));
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment