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
afi
opacce
Commits
d6febc20
Commit
d6febc20
authored
Jan 22, 2018
by
Ghislain Loas
Browse files
dev #69826 refacto to plugin manager
parent
b5243f49
Pipeline
#3339
failed with stage
in 25 minutes and 7 seconds
Changes
13
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
321 additions
and
122 deletions
+321
-122
application/modules/opac/controllers/AbonneController.php
application/modules/opac/controllers/AbonneController.php
+2
-93
application/modules/opac/controllers/BookmarkedSearchesController.php
...modules/opac/controllers/BookmarkedSearchesController.php
+33
-0
application/modules/opac/views/scripts/abonne/settings.phtml
application/modules/opac/views/scripts/abonne/settings.phtml
+6
-6
application/modules/opac/views/scripts/bookmarked-searches/add.phtml
.../modules/opac/views/scripts/bookmarked-searches/add.phtml
+1
-0
library/Class/User/BookmarkedSearch.php
library/Class/User/BookmarkedSearch.php
+5
-0
library/ZendAfi/Controller/Plugin/AdminAuth.php
library/ZendAfi/Controller/Plugin/AdminAuth.php
+3
-1
library/ZendAfi/Controller/Plugin/Manager/BookmarkedSearches.php
.../ZendAfi/Controller/Plugin/Manager/BookmarkedSearches.php
+104
-0
library/ZendAfi/Controller/Plugin/Manager/Manager.php
library/ZendAfi/Controller/Plugin/Manager/Manager.php
+28
-6
library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php
...ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php
+10
-1
library/ZendAfi/Controller/Plugin/ResourceDefinition/BookmarkedSearches.php
...ntroller/Plugin/ResourceDefinition/BookmarkedSearches.php
+42
-0
library/ZendAfi/Form/User/BookmarkedSearch.php
library/ZendAfi/Form/User/BookmarkedSearch.php
+9
-2
library/ZendAfi/View/Helper/Search/Header.php
library/ZendAfi/View/Helper/Search/Header.php
+2
-2
tests/scenarios/bookmarks/SearchTest.php
tests/scenarios/bookmarks/SearchTest.php
+76
-11
No files found.
application/modules/opac/controllers/AbonneController.php
View file @
d6febc20
...
...
@@ -1019,7 +1019,8 @@ class AbonneController extends ZendAfi_Controller_Action {
public
function
settingsAction
()
{
$this
->
view
->
titre
=
$this
->
view
->
_
(
'Mes favoris'
);
$this
->
view
->
bookmarked_searches
=
Class_User_BookmarkedSearch
::
findAllBy
([
'id_user'
=>
$this
->
_user
->
getId
()]);
$this
->
view
->
bookmarked_searches
=
Class_User_BookmarkedSearch
::
findAllBy
([
'id_user'
=>
$this
->
_user
->
getId
(),
'order'
=>
'creation_date desc'
]);
$form
=
ZendAfi_Form_User_Settings
::
forUser
(
$this
->
_user
);
$this
->
view
->
form
=
$form
->
getElements
()
?
$form
...
...
@@ -1223,96 +1224,4 @@ class AbonneController extends ZendAfi_Controller_Action {
$this
->
renderPopupResult
(
$this
->
_
(
'Compléter votre adresse email'
),
$this
->
view
->
render
(
'abonne/ajax-email.phtml'
));
}
public
function
bookmarkSearchAction
()
{
$this
->
view
->
titre
=
$this
->
_
(
'Enregister la recherche dans mes favoris'
);
if
(
!
$this
->
_user
)
return
$this
->
_forward
(
'popup-login'
,
'auth'
,
'opac'
,
[
'redirect'
=>
$this
->
view
->
url
()]);
$this
->
view
->
form
=
$form
=
new
ZendAfi_Form_User_BookmarkSearch
();
$form
->
setAction
(
Class_Url
::
absolute
(
'/abonne/bookmark-search'
));
if
(
!
$this
->
_request
->
isPost
()
||
!
$form
->
isValid
(
$this
->
_request
->
getPost
()))
return
;
$criterias
=
Class_User_BookmarkedSearch
::
newInstance
([
'id_user'
=>
$this
->
_user
->
getId
(),
'label'
=>
$this
->
_getParam
(
'label'
),
'criterias'
=>
$this
->
_getCriterias
()]);
if
(
!
$criterias
->
save
())
{
$this
->
_helper
->
_notify
(
$this
->
_
(
'La recherche n\'a pas été enregistrée dans vos favoris'
));
$this
->
_redirectToReferer
();
}
$this
->
_helper
->
_notify
(
$this
->
_
(
'Cette recherche a été enregistrée dans vos favoris'
));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
protected
function
_getCriterias
()
{
if
(
!
$namespace
=
new
Zend_Session_Namespace
(
'historiqueRecherche'
))
return
null
;
if
(
!
$searches
=
$namespace
->
criteres
)
return
null
;
return
array_pop
(
$searches
);
}
public
function
deleteBookmarkedSearchAction
()
{
$this
->
view
->
titre
=
$this
->
_
(
'Supprimer la recherche de mes favoris'
);
if
(
!
$search
=
$this
->
_checkBookmarkedSearchRequest
())
return
;
$search
->
delete
();
$this
->
_helper
->
_notify
(
$this
->
_
(
'La recherche "%s" a été supprimée.'
,
$search
->
getLabel
()));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
protected
function
_checkBookmarkedSearchRequest
()
{
if
(
!
$this
->
_user
)
{
$this
->
_forward
(
'popup-login'
,
'auth'
,
'opac'
,
[
'redirect'
=>
$this
->
view
->
url
()]);
return
;
}
if
(
!
$search
=
Class_User_BookmarkedSearch
::
find
(
$this
->
_getParam
(
'id'
,
0
)))
{
$this
->
_helper
->
_notify
(
$this
->
_
(
'La recherche demandée est introuvable.'
));
$this
->
_redirectClose
(
$this
->
_getReferer
());
return
;
}
if
(
!
$search
->
belongsTo
(
$this
->
_user
))
{
$this
->
_helper
->
_notify
(
$this
->
_
(
'Cette recherche ne vous appartient pas.'
));
$this
->
_redirectClose
(
$this
->
_getReferer
());
return
;
}
return
$search
;
}
public
function
notifyBookmarkedSearchAction
()
{
if
(
!
$search
=
$this
->
_checkBookmarkedSearchRequest
())
return
;
$search
->
beNotified
()
->
save
();
$this
->
_helper
->
_notify
(
$this
->
_
(
'Les notifications de nouveautés pour la recherche "%s" sont activées.'
,
$search
->
getLabel
()));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
public
function
unnotifyBookmarkedSearchAction
()
{
if
(
!
$search
=
$this
->
_checkBookmarkedSearchRequest
())
return
;
$search
->
beUnnotified
()
->
save
();
$this
->
_helper
->
_notify
(
$this
->
_
(
'Les notifications de nouveautés pour la recherche "%s" sont désactivées.'
,
$search
->
getLabel
()));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
}
\ No newline at end of file
application/modules/opac/controllers/BookmarkedSearchesController.php
0 → 100644
View file @
d6febc20
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class
BookmarkedSearchesController
extends
ZendAfi_Controller_Action
{
public
function
getPlugins
()
{
return
[
'ZendAfi_Controller_Plugin_ResourceDefinition_BookmarkedSearches'
,
'ZendAfi_Controller_Plugin_Manager_BookmarkedSearches'
];
}
public
function
indexAction
()
{
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
}
application/modules/opac/views/scripts/abonne/settings.phtml
View file @
d6febc20
...
...
@@ -9,7 +9,7 @@ if($this->form) {
$description
=
(
new
Class_TableDescription
(
'bookmarked_searches'
))
->
addColumn
(
$this
->
_
(
'Libellé'
),
function
(
$model
)
{
return
$model
->
getLabel
();
})
->
addColumn
(
$this
->
_
(
'Critères'
),
function
(
$model
)
{
return
$this
->
Search_Criterias
(
$model
->
getUnserializedCriterias
());
})
->
addColumn
(
$this
->
_
(
'Date création'
),
function
(
$model
)
{
return
$model
->
getCreationDate
();
})
->
addColumn
(
$this
->
_
(
'Date
de
création'
),
function
(
$model
)
{
return
$model
->
getCreationDate
();
})
->
addRowAction
(
function
(
$model
)
{
return
$this
->
tagPreview
(
Class_Url
::
relative
(
$model
->
getCriteriasUrl
()),
$this
->
_
(
'Voir le résultat de la recherche'
));
...
...
@@ -17,17 +17,17 @@ return $this->tagPreview(Class_Url::relative($model->getCriteriasUrl()),
})
->
addRowAction
(
function
(
$model
)
{
$action
=
'notify
-bookmarked-search
'
;
$action
=
'notify'
;
$label
=
$this
->
_
(
'Me notifier des nouveautés'
);
$icon
=
'toggle_off'
;
if
(
$model
->
isNotified
())
{
$action
=
'unnotify
-bookmarked-search
'
;
$action
=
'unnotify'
;
$label
=
$this
->
_
(
'Annuler la notification des nouveautés'
);
$icon
=
'toggle_on'
;
}
$params
=
[
'controller'
=>
'
a
bo
nne
'
,
$params
=
[
'controller'
=>
'bo
okmarked-searches
'
,
'action'
=>
$action
,
'id'
=>
$model
->
getId
()];
...
...
@@ -40,8 +40,8 @@ return $this->tagPreview(Class_Url::relative($model->getCriteriasUrl()),
->
addRowAction
(
function
(
$model
)
{
$label
=
$this
->
_
(
'Supprimer la recherche "%s"'
,
$model
->
getLabel
());
return
$this
->
tagAnchor
(
$this
->
url
([
'controller'
=>
'
a
bo
nne
'
,
'action'
=>
'delete
-bookmarked-search
'
,
return
$this
->
tagAnchor
(
$this
->
url
([
'controller'
=>
'bo
okmarked-searches
'
,
'action'
=>
'delete'
,
'id'
=>
$model
->
getId
()],
null
,
true
),
Class_Admin_Skin
::
current
()
->
renderActionIconOn
(
'delete'
,
$this
,
[
'title'
=>
$label
,
...
...
application/modules/opac/views/scripts/bookmarked-searches/add.phtml
0 → 100644
View file @
d6febc20
<?php
echo
$this
->
renderForm
(
$this
->
form
);
?>
library/Class/User/BookmarkedSearch.php
View file @
d6febc20
...
...
@@ -77,4 +77,9 @@ class Class_User_BookmarkedSearch extends Storm_Model_Abstract {
public
function
beUnnotified
()
{
return
$this
->
setNotified
(
0
);
}
public
function
getLibelle
()
{
return
$this
->
getLabel
();
}
}
\ No newline at end of file
library/ZendAfi/Controller/Plugin/AdminAuth.php
View file @
d6febc20
...
...
@@ -52,7 +52,9 @@ class ZendAfi_Controller_Plugin_AdminAuth extends Zend_Controller_Plugin_Abstrac
$action
=
'sitedown'
;
}
if
((
!
$user
=
Class_Users
::
getIdentity
())
&&
(
$controller
==
"abonne"
&&
$action
!==
"authenticate"
))
{
if
((
!
$user
=
Class_Users
::
getIdentity
())
&&
$action
!==
"authenticate"
&&
in_array
(
$controller
,
[
"abonne"
,
'bookmarked-searches'
]))
{
$request
->
setParam
(
'redirect'
,
Class_Url
::
absolute
());
$controller
=
'auth'
;
$action
=
(
$request
->
getParam
(
'render'
)
==
'popup'
)
?
'popup-login'
:
'login'
;
...
...
library/ZendAfi/Controller/Plugin/Manager/BookmarkedSearches.php
0 → 100644
View file @
d6febc20
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class
ZendAfi_Controller_Plugin_Manager_BookmarkedSearches
extends
ZendAfi_Controller_Plugin_Manager_Manager
{
protected
$_user
;
public
function
init
()
{
parent
::
init
();
$this
->
_user
=
Class_Users
::
getIdentity
();
}
protected
function
_getPost
()
{
$post
=
parent
::
_getPost
();
$post
[
'id_user'
]
=
$this
->
_user
->
getId
();
$post
[
'criterias'
]
=
$this
->
_getCriterias
();
return
$post
;
}
protected
function
_getCriterias
()
{
if
(
!
$namespace
=
new
Zend_Session_Namespace
(
'historiqueRecherche'
))
return
null
;
if
(
!
$searches
=
$namespace
->
criteres
)
return
null
;
return
array_pop
(
$searches
);
}
protected
function
_checkBookmarkedSearchRequest
()
{
if
(
!
$search
=
$this
->
_findModel
())
{
$this
->
_helper
->
_notify
(
$this
->
_
(
'La recherche demandée est introuvable.'
));
$this
->
_redirectClose
(
$this
->
_getReferer
());
return
;
}
if
(
!
$search
->
belongsTo
(
$this
->
_user
))
{
$this
->
_helper
->
_notify
(
$this
->
_
(
'Cette recherche ne vous appartient pas.'
));
$this
->
_redirectClose
(
$this
->
_getReferer
());
return
;
}
return
$search
;
}
protected
function
_redirectToIndex
()
{
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
protected
function
_canDelete
(
$model
)
{
return
$model
->
belongsTo
(
$this
->
_user
);
}
public
function
notifyAction
()
{
if
(
!
$search
=
$this
->
_checkBookmarkedSearchRequest
())
return
;
$search
->
beNotified
()
->
save
();
$this
->
_helper
->
_notify
(
$this
->
_
(
'Les notifications de nouveautés pour la recherche "%s" sont activées.'
,
$search
->
getLabel
()));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
public
function
unnotifyAction
()
{
if
(
!
$search
=
$this
->
_checkBookmarkedSearchRequest
())
return
;
$search
->
beUnnotified
()
->
save
();
$this
->
_helper
->
_notify
(
$this
->
_
(
'Les notifications de nouveautés pour la recherche "%s" sont désactivées.'
,
$search
->
getLabel
()));
return
$this
->
_redirectClose
(
$this
->
_getReferer
());
}
public
function
editAction
()
{
return
$this
->
_redirectToIndex
();
}
}
library/ZendAfi/Controller/Plugin/Manager/Manager.php
View file @
d6febc20
...
...
@@ -165,18 +165,24 @@ class ZendAfi_Controller_Plugin_Manager_Manager extends ZendAfi_Controller_Plugi
}
public
function
deleteAction
()
{
if
(
$this
->
_response
->
isRedirect
())
return
;
if
(
$model
=
$this
->
_findModel
())
{
$values
=
$this
->
_getCustomFieldModelValues
(
$model
);
$values
->
deleteValues
();
$model
->
delete
();
$this
->
_helper
->
notify
(
$this
->
_getSuccessfulDeleteMessage
(
$model
));
if
(
!
$model
=
$this
->
_findModel
())
return
$this
->
_redirectToIndex
();
if
(
!
$this
->
_canDelete
(
$model
))
{
$this
->
_helper
->
notify
(
$this
->
_view
->
_
(
'Vous n\'avez pas la permission "%s"'
,
$this
->
_getDeleteActionTitle
(
$model
)));
return
$this
->
_redirectToIndex
();
}
$values
=
$this
->
_getCustomFieldModelValues
(
$model
);
$values
->
deleteValues
();
$model
->
delete
();
$this
->
_helper
->
notify
(
$this
->
_getSuccessfulDeleteMessage
(
$model
));
$this
->
_redirectToIndex
();
$this
->
_getDoAfterDelete
(
$model
);
}
...
...
@@ -190,6 +196,11 @@ class ZendAfi_Controller_Plugin_Manager_Manager extends ZendAfi_Controller_Plugi
}
protected
function
_canDelete
(
$model
)
{
return
true
;
}
protected
function
_getEditUrl
(
$model
)
{
return
[
'module'
=>
'admin'
,
'action'
=>
'edit'
,
...
...
@@ -442,11 +453,22 @@ class ZendAfi_Controller_Plugin_Manager_Manager extends ZendAfi_Controller_Plugi
}
public
function
visitDeleteActionTitle
(
$callback
)
{
$this
->
_delete_action_title
=
$callback
;
return
$this
;
}
protected
function
_getEditActionTitle
(
$model
)
{
return
call_user_func
(
$this
->
_edit_action_title
,
$model
);
}
protected
function
_getDeleteActionTitle
(
$model
)
{
return
call_user_func
(
$this
->
_delete_action_title
,
$model
);
}
public
function
visitSuccessfulSaveMessage
(
$callback
)
{
$this
->
_successful_save_message
=
$callback
;
return
$this
;
...
...
library/ZendAfi/Controller/Plugin/ResourceDefinition/Abstract.php
View file @
d6febc20
...
...
@@ -146,7 +146,12 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen
public
function
editActionTitle
(
$model
)
{
return
sprintf
(
$this
->
titleForAction
(
'edit'
),
$model
->
getLibelle
());
return
sprintf
(
$this
->
titleForAction
(
'edit'
),
$model
->
getLibelle
());
}
public
function
deleteActionTitle
(
$model
)
{
return
sprintf
(
$this
->
titleForAction
(
'delete'
),
$model
->
getLibelle
());
}
...
...
@@ -307,6 +312,10 @@ abstract class ZendAfi_Controller_Plugin_ResourceDefinition_Abstract extends Zen
{
return
$this
->
editActionTitle
(
$model
);
})
->
visitDeleteActionTitle
(
function
(
$model
)
{
return
$this
->
deleteActionTitle
(
$model
);
})
->
visitSuccessfulSaveMessage
(
function
(
$model
)
{
return
$this
->
successfulSaveMessage
(
$model
);
...
...
library/ZendAfi/Controller/Plugin/ResourceDefinition/BookmarkedSearches.php
0 → 100644
View file @
d6febc20
<?php
/**
* Copyright (c) 2012-2017, Agence Française Informatique (AFI). All rights reserved.
*
* BOKEH is free software; you can redistribute it and/or modify
* it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
* the Free Software Foundation.
*
* There are special exceptions to the terms and conditions of the AGPL as it
* is applied to this software (see README file).
*
* BOKEH is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
* along with BOKEH; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
class
ZendAfi_Controller_Plugin_ResourceDefinition_BookmarkedSearches
extends
ZendAfi_Controller_Plugin_ResourceDefinition_Abstract
{
public
function
getDefinitions
()
{
return
[
'model'
=>
[
'class'
=>
'Class_User_BookmarkedSearch'
,
'name'
=>
'search'
,
'order'
=>
'label'
],
'messages'
=>
[
'successful_save'
=>
$this
->
_
(
'La recherche "%s" a été enregistrée dans mes favoris'
),
'successful_add'
=>
$this
->
_
(
'La recherche "%s" a été enregistrée dans mes favoris'
),
'successful_delete'
=>
$this
->
_
(
'La recherche "%s" a été supprimée de mes favoris'
)],
'actions'
=>
[
'add'
=>
[
'title'
=>
$this
->
_
(
'Enregister la recherche dans mes favoris'
)],
'edit'
=>
[
'title'
=>
$this
->
_
(
'Enregister la recherche dans mes favoris'
)],
'delete'
=>
[
'title'
=>
$this
->
_
(
'Supprimer la recherche de mes favoris'
)]],
'form_class_name'
=>
'ZendAfi_Form_User_BookmarkedSearch'
,
];
}
}
library/ZendAfi/Form/User/BookmarkSearch.php
→
library/ZendAfi/Form/User/Bookmark
ed
Search.php
View file @
d6febc20
...
...
@@ -20,7 +20,7 @@
*/
class
ZendAfi_Form_User_BookmarkSearch
extends
ZendAfi_Form
{
class
ZendAfi_Form_User_Bookmark
ed
Search
extends
ZendAfi_Form
{
public
function
init
()
{
parent
::
init
();
$this
...
...
@@ -31,7 +31,14 @@ class ZendAfi_Form_User_BookmarkSearch extends ZendAfi_Form {
'allowEmpty'
=>
false
,
'placeholder'
=>
$this
->
_
(
'Titre de votre recherche'
)])
->
addDisplayGroup
([
'label'
],
->
addElement
(
'checkbox'
,
'notified'
,
[
'label'
=>
$this
->
_
(
'Me notifier des nouveautés par email'
),
'required'
=>
true
,
'allowEmpty'
=>
false
])
->
addDisplayGroup
([
'label'
,
'notified'
],
'group_bookmark_search'
);
}
}
\ No newline at end of file
library/ZendAfi/View/Helper/Search/Header.php
View file @
d6febc20
...
...
@@ -144,8 +144,8 @@ class ZendAfi_View_Helper_Search_Header extends ZendAfi_View_Helper_BaseHelper {
return
''
;
return
$this
->
_tag
(
'span'
,
$this
->
view
->
tagAnchor
(
$this
->
view
->
url
([
'controller'
=>
'
a
bo
nne
'
,
'action'
=>
'
bookmark-search
'
],
null
,
true
),
$this
->
view
->
tagAnchor
(
$this
->
view
->
url
([
'controller'
=>
'bo
okmarked-searches
'
,
'action'
=>
'
add
'
],
null
,
true
),
$this
->
_
(
'Enregistrer ma recherche'
),
[
'title'
=>
$this
->
_
(
'Enregistrer ma recherche dans mes favoris'
),
'data-popup'
=>
true
]),
...
...
tests/scenarios/bookmarks/SearchTest.php
View file @
d6febc20
...
...
@@ -36,7 +36,7 @@ class Bookmarks_SearchLinkTest extends AbstractControllerTestCase {
/** @test */
public
function
linkToBookmarkSearchShouldBePresent
()
{
$this
->
assertXPathContentContains
(
'//a[contains(@href, "/
abonne/
bookmark-search")]'
,
'Enregistrer ma recherche'
);
$this
->
assertXPathContentContains
(
'//a[contains(@href, "/bookmark
ed
-search
es/add
")]'
,
'Enregistrer ma recherche'
);
}
}
...
...
@@ -77,7 +77,7 @@ class Bookmarks_SearchAbonneBookmarkSearchDispatchTest extends Bookmarks_Search
'criterias'
=>
''
,
'creation_date'
=>
'2018-01-17 15:05:57'
]);
$this
->
dispatch
(
'/
abonne/
bookmark-search'
,
true
);
$this
->
dispatch
(
'/bookmark
ed
-search
es/add
'
,
true
);
}
...
...
@@ -85,6 +85,12 @@ class Bookmarks_SearchAbonneBookmarkSearchDispatchTest extends Bookmarks_Search
public
function
formShouldContainsLabel
()
{
$this
->
assertXPath
(
'//form//input[@type="text"][@name="label"]'
);
}
/** @test */
public
function
formShouldContainsNotified
()
{
$this
->
assertXPath
(
'//form//input[@type="checkbox"][@name="notified"]'
);
}
}
...
...
@@ -93,7 +99,8 @@ class Bookmarks_SearchAbonneBookmarkSearchPostTest extends Bookmarks_SearchWith
public
function
setUp
()
{
parent
::
setUp
();
Class_User_BookmarkedSearch
::
setTimeSource
(
new
TimeSourceForTest
(
'2018-01-17 01:01:01'
));
$this
->
postDispatch
(
'/abonne/bookmark-search'
,
[
'label'
=>
'search'
]);
$this
->
postDispatch
(
'/bookmarked-searches/add'
,
[
'label'
=>
'search'
,
'notified'
=>
'1'
]);
}
...
...
@@ -119,6 +126,12 @@ class Bookmarks_SearchAbonneBookmarkSearchPostTest extends Bookmarks_SearchWith
public
function
davisSearchShouldBeBookmarkedInUserSettings
()
{
$this
->
assertEquals
(
'Miles Davis'
,
Class_User_BookmarkedSearch
::
find
(
1
)
->
getUnserializedCriterias
()
->
getParam
(
'rech_auteurs'
));
}
/** @test */
public
function
bookmarkedSearchShouldBeNotified
()
{
$this
->
assertTrue
(
Class_User_BookmarkedSearch
::
find
(
1
)
->
isNotified
());
}
}
...
...
@@ -132,7 +145,7 @@ class Bookmarks_SearchAbonneNotLoggedTest extends AbstractControllerTestCase {
public
function
setUp
()
{
parent
::
setUp
();
ZendAfi_Auth
::
getInstance
()
->
clearIdentity
();
$this
->
dispatch
(
'/
abonne/
bookmark-search'
,
true
);
$this
->
dispatch
(
'/bookmark
ed
-search
es/add
'
,
true
);
}
...
...
@@ -207,7 +220,7 @@ class Bookmarks_SearchAbonneSettingsTest extends Bookmarks_SearchWithSessionAbst
/** @test */
public
function
tableShouldContainsDeleteButton
()
{
$this
->
assertXPath
(
'//td//a[contains(@onclick, "return confirm")][contains(@href,"/
abonne/delete-
bookmarked-search/id/5")]'
);
$this
->
assertXPath
(
'//td//a[contains(@onclick, "return confirm")][contains(@href,"/bookmarked-search
es/delete
/id/5")]'
);
}
...
...
@@ -225,13 +238,13 @@ class Bookmarks_SearchAbonneSettingsTest extends Bookmarks_SearchWithSessionAbst
/** @test */
public
function
tableShoulContainsLinkEnableMailNotification
()
{
$this
->
assertXPath
(
'//td//a[contains(@href, "/
abonne/notify-
bookmarked-search/id/5")]'
);
$this
->
assertXPath
(
'//td//a[contains(@href, "/bookmarked-search
es/notify
/id/5")]'
);
}
/** @test */
public
function
tableShoulContainsLinkUnableMailNotification
()
{
$this
->
assertXPath
(
'//td//a[contains(@href, "/
abonne/unnotify-
bookmarked-search/id/8")]'
);
$this
->
assertXPath
(
'//td//a[contains(@href, "/bookmarked-search
es/unnotify
/id/8")]'
);
}
}
...
...
@@ -251,7 +264,7 @@ class Bookmarks_SearchDeleteBookmarkedSearchTest extends Bookmarks_SearchWithSes
'criterias'
=>
''
,
'creation_date'
=>
'2018-01-17 15:05:57'
]);
$this
->
dispatch
(
'/
abonne/delete-
bookmarked-search/id/5'
,
true
);
$this
->
dispatch
(
'/bookmarked-search
es/delete
/id/5'
,
true
);
}
...
...
@@ -263,7 +276,13 @@ class Bookmarks_SearchDeleteBookmarkedSearchTest extends Bookmarks_SearchWithSes
/** @test */
public
function
notifyMessageShouldBeRechercheSupprimee
()
{
$this
->
assertFlashMessengerContentContains
(
'La recherche "Miles Davis" a été supprimée.'
);
$this
->
assertFlashMessengerContentContains
(
'La recherche "Miles Davis" a été supprimée de mes favoris'
);
}
/** @test */
public
function
shouldRedirectToReferer
()
{
$this
->
assertRedirectTo
(
'/'
);
}