Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
php-modules
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
library
php-modules
Commits
d2fc5fe3
Commit
d2fc5fe3
authored
6 years ago
by
Hoop, Bert Jan de
Browse files
Options
Downloads
Patches
Plain Diff
L05DOCBST-38 add get_next_ofs method
parent
e27d7345
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/library/Webquery.php
+21
-1
21 additions, 1 deletion
src/library/Webquery.php
tests/library/WebqueryTest.php
+2
-0
2 additions, 0 deletions
tests/library/WebqueryTest.php
with
23 additions
and
1 deletion
src/library/Webquery.php
+
21
−
1
View file @
d2fc5fe3
...
@@ -345,7 +345,7 @@ class Webquery {
...
@@ -345,7 +345,7 @@ class Webquery {
/**
/**
* return value of the hits element in search response
* return value of the hits element in search response
* @return number of hits or false if there is no valid search reponse
* @return number of hits or false if there is no valid search re
s
ponse
*/
*/
public
function
get_hits
()
{
public
function
get_hits
()
{
...
@@ -374,6 +374,26 @@ class Webquery {
...
@@ -374,6 +374,26 @@ class Webquery {
}
}
/**
* return value of wq_ofs attribute of next element in search response
* @return value of next wq_ofs or false if there is no valid search response
*/
public
function
get_next_ofs
()
{
$resp_xml
=
$this
->
get_resp_xml
();
if
(
!
isset
(
$resp_xml
))
{
return
false
;
}
$next
=
$resp_xml
->
xpath
(
"//next"
);
if
(
empty
(
$next
))
{
return
false
;
}
$attr
=
$next
[
0
]
->
attributes
();
return
empty
(
$attr
[
'wq_ofs'
])
?
false
:
(
string
)
$attr
[
'wq_ofs'
];
}
/**
/**
* convert xml tree to x-www-form-urlencoded string
* convert xml tree to x-www-form-urlencoded string
* @param SimpleXMLElement $xml xml tree
* @param SimpleXMLElement $xml xml tree
...
...
This diff is collapsed.
Click to expand it.
tests/library/WebqueryTest.php
+
2
−
0
View file @
d2fc5fe3
...
@@ -143,6 +143,7 @@ EOT;
...
@@ -143,6 +143,7 @@ EOT;
$this
->
assertEquals
(
''
,
$wq
->
get_error_message
(),
'1st: search response error message'
);
$this
->
assertEquals
(
''
,
$wq
->
get_error_message
(),
'1st: search response error message'
);
$this
->
assertEquals
(
1
,
$wq
->
get_hits
(),
'1st: search response hits'
);
$this
->
assertEquals
(
1
,
$wq
->
get_hits
(),
'1st: search response hits'
);
$this
->
assertTrue
(
$wq
->
has_next
(),
'1st: search response has next element'
);
$this
->
assertTrue
(
$wq
->
has_next
(),
'1st: search response has next element'
);
$this
->
assertEquals
(
1
,
$wq
->
get_next_ofs
(),
'1st: search response next wq_ofs'
);
// second request fails
// second request fails
$wq
->
set_query
(
'record=nothing'
);
$wq
->
set_query
(
'record=nothing'
);
...
@@ -164,6 +165,7 @@ EOT;
...
@@ -164,6 +165,7 @@ EOT;
$this
->
assertEquals
(
'nothing found'
,
$wq
->
get_error_message
(),
'2nd: search response error message'
);
$this
->
assertEquals
(
'nothing found'
,
$wq
->
get_error_message
(),
'2nd: search response error message'
);
$this
->
assertEquals
(
false
,
$wq
->
get_hits
(),
'2nd: search response hits'
);
$this
->
assertEquals
(
false
,
$wq
->
get_hits
(),
'2nd: search response hits'
);
$this
->
assertFalse
(
$wq
->
has_next
(),
'1st: search response has next element'
);
$this
->
assertFalse
(
$wq
->
has_next
(),
'1st: search response has next element'
);
$this
->
assertEquals
(
false
,
$wq
->
get_next_ofs
(),
'2nd: search response next wq_ofs'
);
$this
->
assertEquals
(
2
,
count
(
$request_history
),
'request history count'
);
$this
->
assertEquals
(
2
,
count
(
$request_history
),
'request history count'
);
// check first request
// check first request
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment