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
685bfae0
Commit
685bfae0
authored
May 14, 2019
by
Henri-Damien LAURENT
Browse files
hotline#92312 : UserSettings : Prevent last library to be deleted from Settings
parent
91632d18
Pipeline
#7381
passed with stage
in 36 minutes and 36 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
68 additions
and
5 deletions
+68
-5
VERSIONS_HOTLINE/92312
VERSIONS_HOTLINE/92312
+1
-0
application/modules/opac/controllers/AbonneController.php
application/modules/opac/controllers/AbonneController.php
+6
-1
library/ZendAfi/View/Helper/Notice/ExemplairesTable.php
library/ZendAfi/View/Helper/Notice/ExemplairesTable.php
+6
-1
tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php
...modules/opac/controllers/AbonneControllerSettingsTest.php
+37
-0
tests/library/Class/UsersTest.php
tests/library/Class/UsersTest.php
+3
-3
tests/scenarios/bookmarks/LibrariesTest.php
tests/scenarios/bookmarks/LibrariesTest.php
+15
-0
No files found.
VERSIONS_HOTLINE/92312
0 → 100644
View file @
685bfae0
- ticket #92312 : Favoris Utilisateurs : Interdire la suppression d'une bibliothèque si c'est la seule en favori
\ No newline at end of file
application/modules/opac/controllers/AbonneController.php
View file @
685bfae0
...
...
@@ -1127,6 +1127,11 @@ class AbonneController extends ZendAfi_Controller_Action {
$this
->
view
->
form
=
$form
=
ZendAfi_Form_User_Settings
::
forUser
(
$this
->
_user
);
if
(
$this
->
_request
->
isPost
()
&&
!
$this
->
_getParam
(
'library_ids'
))
{
$this
->
_helper
->
notify
(
$this
->
_
(
'Au moins une bibliothèque favorite doit être sélectionnée!'
));
return
;
}
if
(
$this
->
_request
->
isPost
())
{
$data
=
$this
->
_request
->
getPost
();
unset
(
$data
[
'id_items'
]);
...
...
@@ -1539,4 +1544,4 @@ class AbonneController extends ZendAfi_Controller_Action {
$form
->
addDecorator
(
'Errors'
);
}
}
}
\ No newline at end of file
}
library/ZendAfi/View/Helper/Notice/ExemplairesTable.php
View file @
685bfae0
...
...
@@ -108,8 +108,13 @@ abstract class ZendAfi_View_Helper_Notice_ExemplairesTable_LibraryOrAnnex extend
if
(
!
$user
=
Class_Users
::
getIdentity
())
return
$this
->
_bookmarkLink
(
$this
->
_getId
());
foreach
(
$user
->
getBookmarkedLibraries
()
as
$annex_or_lib
)
{
$bookmarked_libraries
=
$user
->
getBookmarkedLibraries
();
foreach
(
$bookmarked_libraries
as
$annex_or_lib
)
{
$annex_or_lib_id
=
$annex_or_lib
->
getId
();
if
(
count
(
$bookmarked_libraries
)
<
2
)
continue
;
if
(
$this
->
_getId
()
==
$annex_or_lib_id
)
return
$this
->
_unbookmarkLink
(
$annex_or_lib_id
);
continue
;
...
...
tests/application/modules/opac/controllers/AbonneControllerSettingsTest.php
View file @
685bfae0
...
...
@@ -241,6 +241,43 @@ class AbonneControllerSettingsFormPostTest extends AbonneControllerSettingsTestC
}
class
AbonneControllerSettingsFormChangeTest
extends
AbonneControllerSettingsTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
$this
->
fixture
(
'Class_Bib'
,
[
'id'
=>
59
,
'libelle'
=>
'ANNECY'
]);
$this
->
_user
->
setBookmarkedLibraries
([
56
])
->
save
();
$post2
=
[
'library_ids'
=>
''
];
$this
->
postDispatch
(
'/abonne/manage-settings'
,
$post2
);
}
/** @test */
public
function
userSettingsShouldNotHaveBeenCleared
()
{
$this
->
assertEquals
(
1
,
count
(
$this
->
_user
->
getBookmarkedLibraries
()));
}
/** @test */
public
function
userSettingsLibraryIdShouldBe56
()
{
$this
->
assertEquals
(
56
,
$this
->
_user
->
getBookmarkedLibraries
()[
0
]
->
getId
());
}
/** @test */
public
function
notificationShouldContainsAuMoinsUneBibliotheque
()
{
$this
->
assertFlashMessengerContentContains
(
"Au moins une bibliothèque"
);
}
}
class
AbonneControllerSettingsViewableDomainTest
extends
AbonneControllerSettingsTestCase
{
public
function
setUp
()
{
...
...
tests/library/Class/UsersTest.php
View file @
685bfae0
...
...
@@ -557,7 +557,7 @@ class UserGetBookmarkedLibraryTest extends ModelTestCase {
'libelle'
=>
'Médiathèque de Valleiry'
]);
$annex
=
$this
->
fixture
(
'Class_CodifAnnexe'
,
[
'id'
=>
5
6
,
[
'id'
=>
5
8
,
'libelle'
=>
'Médiathèque de Valleiry'
]);
$this
->
fixture
(
'Class_Bib'
,
...
...
@@ -576,8 +576,8 @@ class UserGetBookmarkedLibraryTest extends ModelTestCase {
/** @test */
public
function
stephBookmarkedLibraryShouldBe
Vallery
()
{
$this
->
assertContains
(
'5
6
'
,
Class_Users
::
find
(
15
)
->
getSettings
());
public
function
stephBookmarkedLibraryShouldBe
58
()
{
$this
->
assertContains
(
'5
8
'
,
Class_Users
::
find
(
15
)
->
getSettings
());
}
}
...
...
tests/scenarios/bookmarks/LibrariesTest.php
View file @
685bfae0
...
...
@@ -267,6 +267,21 @@ abstract class Bookmarks_LibrariesItemsTableWithAnnexTestCase extends AbstractCo
class
Bookmarks_LibrariesItemsTableWithOneDefaultAnnexTest
extends
Bookmarks_LibrariesItemsTableWithAnnexTestCase
{
public
function
setUp
()
{
parent
::
setUp
();
Class_Users
::
find
(
89
)
->
setBookmarkedLibraries
([
654321
])
->
save
();
$this
->
buildItems
();
$this
->
dispatch
(
'/noticeajax/exemplaires/id/24765'
);
}
/** @test */
public
function
linkToUnbookmarkLibraryAdmoShouldBePresent
()
{
$this
->
assertNotXPath
(
'//a[contains(@href, "/remove-library-from-bookmarks/library_id/654321")]'
);
}
}
class
Bookmarks_LibrariesItemsTableWithAnnexTest
extends
Bookmarks_LibrariesItemsTableWithAnnexTestCase
{
public
function
setUp
()
{
...
...
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