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
0631bb67
Commit
0631bb67
authored
Oct 03, 2019
by
Patrick Barroca
😁
Browse files
dev #93423 : add location coordinates to libraries JSON export
parent
da2c827a
Pipeline
#8472
passed with stage
in 42 minutes and 55 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
18 deletions
+66
-18
VERSIONS_WIP/93423
VERSIONS_WIP/93423
+1
-0
application/modules/opac/controllers/BibController.php
application/modules/opac/controllers/BibController.php
+10
-0
tests/application/modules/opac/controllers/BibControllerIndexActionTest.php
...modules/opac/controllers/BibControllerIndexActionTest.php
+55
-18
No files found.
VERSIONS_WIP/93423
0 → 100644
View file @
0631bb67
- ticket #93423 : Open Data : Ajout des coordonnées du lieu dans la liste des bibliothèques en JSON
\ No newline at end of file
application/modules/opac/controllers/BibController.php
View file @
0631bb67
...
...
@@ -85,6 +85,16 @@ class BibController extends ZendAfi_Controller_Action {
$fields
[
'openings'
]
=
$openings
;
$fields
[
'latitude'
]
=
''
;
$fields
[
'longitude'
]
=
''
;
if
((
$location
=
$library
->
getLieu
())
&&
$location
->
hasLatitude
()
&&
$location
->
hasLongitude
())
{
$fields
[
'latitude'
]
=
$location
->
getLatitude
();
$fields
[
'longitude'
]
=
$location
->
getLongitude
();
}
return
$fields
;
}
...
...
tests/application/modules/opac/controllers/BibControllerIndexActionTest.php
View file @
0631bb67
...
...
@@ -111,7 +111,9 @@ class BibControllerIndexActionTest extends AbstractControllerTestCase {
class
BibControllerIndexActionFormatJsonTest
extends
AbstractControllerTestCase
{
protected
$_storm_default_to_volatile
=
true
,
$_json
;
protected
$_storm_default_to_volatile
=
true
,
$_json
;
public
function
setUp
()
{
parent
::
setUp
();
...
...
@@ -125,7 +127,10 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
'ville'
=>
'Annecy'
,
'url_web'
=>
''
,
'cp'
=>
'74000'
,
'ouvertures'
=>
$ouvertures
]);
'ouvertures'
=>
$ouvertures
,
'lieu'
=>
$this
->
fixture
(
'Class_Lieu'
,
[
'id'
=>
44
,
'libelle'
=>
'Annecy'
])]);
$this
->
fixture
(
'Class_Bib'
,
[
'id'
=>
586
,
...
...
@@ -134,7 +139,12 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
'ville'
=>
'Cran-Gevrier'
,
'cp'
=>
'74960'
,
'url_web'
=>
''
,
'gln'
=>
'UN GROS GLN'
]);
'gln'
=>
'UN GROS GLN'
,
'lieu'
=>
$this
->
fixture
(
'Class_Lieu'
,
[
'id'
=>
45
,
'libelle'
=>
'Cran'
,
'latitude'
=>
'45.90644'
,
'longitude'
=>
'6.10739'
])]);
$this
->
fixture
(
'Class_CustomField'
,
[
'id'
=>
7
,
...
...
@@ -157,48 +167,75 @@ class BibControllerIndexActionFormatJsonTest extends AbstractControllerTestCase
$annecy
->
saveWithCustomFields
();
$this
->
dispatch
(
'opac/bib/index/format/json'
,
true
);
$this
->
_json
=
$this
->
_response
->
getBody
();
$this
->
_json
=
json_decode
(
$this
->
_response
->
getBody
()
)
;
}
/** @test */
public
function
jsonShouldContainsLabel
MediathequeAnnecy
()
{
$this
->
assert
Contains
(
'M\u00e9diath\u00e8
que d\'Annecy'
,
$this
->
_json
);
public
function
firstLabelShouldBe
MediathequeAnnecy
()
{
$this
->
assert
Equals
(
'Médiathè
que d\'Annecy'
,
$this
->
_json
[
0
]
->
libelle
);
}
/** @test */
public
function
jsonShouldContainsLabel
MediathequeDeCran
()
{
$this
->
assert
Contains
(
'M\u00e9diath\u00e8
que de Cran'
,
$this
->
_json
);
public
function
secondLabelShouldBe
MediathequeDeCran
()
{
$this
->
assert
Equals
(
'Médiathè
que de Cran'
,
$this
->
_json
[
1
]
->
libelle
);
}
/** @test */
public
function
jso
nShouldNot
ContainsUnGrosGln
()
{
$this
->
assert
NotContains
(
'UN GROS GLN'
,
$this
->
_json
);
public
function
cranGl
nShouldNot
BeSet
()
{
$this
->
assert
False
(
isset
(
$this
->
_json
[
1
]
->
gln
)
);
}
/** @test */
public
function
jsonShouldContainsRestauration
()
{
$this
->
assert
Contains
(
'Restauration
'
,
$this
->
_json
);
public
function
annecyLatitudeShouldBeEmpty
()
{
$this
->
assert
Equals
(
'
'
,
$this
->
_json
[
0
]
->
latitude
);
}
/** @test */
public
function
jsonShouldContainsServices
()
{
$this
->
assert
Contains
(
'Services
'
,
$this
->
_json
);
public
function
cranLatitudeShouldBe45
()
{
$this
->
assert
Equals
(
'45.90644
'
,
$this
->
_json
[
1
]
->
latitude
);
}
/** @test */
public
function
jsonShouldContainsPublic
()
{
$this
->
assert
Contains
(
'Public
'
,
$this
->
_json
);
public
function
cranLongitudeShouldBe6
()
{
$this
->
assert
Equals
(
'6.10739
'
,
$this
->
_json
[
1
]
->
longitude
);
}
/** @test */
public
function
jsonShouldContainsMardi
()
{
$this
->
assertContains
(
'"jour_semaine":2'
,
$this
->
_json
);
public
function
annecyShouldHave2CustomFields
()
{
$this
->
assertEquals
(
2
,
count
(
$this
->
_json
[
0
]
->
custom_fields
));
return
$this
->
_json
[
0
]
->
custom_fields
;
}
/**
* @test
* @depends annecyShouldHave2CustomFields
*/
public
function
firstAnnecyFieldShouldBePublic
(
$fields
)
{
$this
->
assertEquals
(
'Public'
,
$fields
[
0
]
->
label
);
$this
->
assertEquals
(
''
,
$fields
[
0
]
->
value
);
}
/**
* @test
* @depends annecyShouldHave2CustomFields
*/
public
function
secondAnnecyFieldShouldBeServices
(
$fields
)
{
$this
->
assertEquals
(
'Services'
,
$fields
[
1
]
->
label
);
$this
->
assertEquals
(
'Wifi;Restauration'
,
$fields
[
1
]
->
value
);
}
/** @test */
public
function
annecyShouldBeOpenedTuesday
()
{
$this
->
assertEquals
(
'2'
,
$this
->
_json
[
0
]
->
openings
[
0
]
->
jour_semaine
);
}
}
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