Req #19276 [Opn->Ana]: Mock: per-URL responses
| From: | borz_off at cs dot msu dot su | Date: | Wed, 21 Mar 2012 13:22:11 +0000 |
| Subject: | Req #19276 [Opn->Ana]: Mock: per-URL responses | ||
| References: | 1 | Groups: | php.pear.bugs |
| Request: | Send a blank email to pear-bugs+get-8418@lists.php.net to get a copy of this message | ||
Edit report at https://pear.php.net/bugs/bug.php?id=19276&edit=1
ID: 19276
Updated by: borz_off@cs.msu.su
Reported By: cweiske at php dot net
Summary: Mock: per-URL responses
-Status: Open
+Status: Analyzed
Type: Feature/Change Request
Package: HTTP_Request2
Package Version: SVN
PHP Version: Irrelevant
-Assigned To:
+Assigned To: avb
-Roadmap Versions:
+Roadmap Versions: 2.1.0
New Comment:
-Status: Open
+Status: Analyzed
-Assigned To:
+Assigned To: avb
-Roadmap Versions:
+Roadmap Versions: 2.1.0
Well, we can easily add a second parameter to addResponse():
public function addResponse($response, $url = '')
where $url may be either a full URL or a pattern (?). When choosing
which response to send, we use the first one with an URL match or
without URL set (this keeps BC). Sounds good enough?
Matching on other stuff (methods / headers / body) starts to look
suspiciously like what the web server is doing. I don't think that
reinventing web server in Mock_Adapter is a worthwhile goal.
Previous Comments:
------------------------------------------------------------------------
[2012-02-04 19:38:48] cweiske
Description:
------------
When unit-testing classes/applications that use HTTP_Request2, one has
to know the internals about what URLs are fetched when so that the
correct mock responses can be set in the correct order.
Sometimes I know which URLs need to be fetched, but not in which order,
which makes it impossible to set the correct mock responses.
I'd like to be able to set per-url responses, so that the mock adapter
returns the correct response depending on the URL. Maybe also matches on
headers (e.g. for content-type switching).
------------------------------------------------------------------------
--
Edit this bug report at https://pear.php.net/bugs/bug.php?id=19276&edit=1