File tree Expand file tree Collapse file tree 3 files changed +14
-7
lines changed
test/Bitbucket/Tests/API/Http/Listener Expand file tree Collapse file tree 3 files changed +14
-7
lines changed Original file line number Diff line number Diff line change 1111
1212namespace Bitbucket \API ;
1313
14- use Bitbucket \API \Http \Listener \RequestListener ;
14+ use Bitbucket \API \Http \Listener \NormalizeArrayListener ;
1515use Buzz \Message \MessageInterface ;
1616use Buzz \Message \RequestInterface ;
1717use Buzz \Client \ClientInterface as BuzzClientInterface ;
@@ -62,7 +62,7 @@ public function __construct(BuzzClientInterface $client = null)
6262 $ this ->client = (is_null ($ client )) ? new Curl : $ client ;
6363 $ this ->httpClient = new Client (array (), $ client );
6464
65- $ this ->httpClient ->addListener (new RequestListener ());
65+ $ this ->httpClient ->addListener (new NormalizeArrayListener ());
6666
6767 return $ this ;
6868 }
Original file line number Diff line number Diff line change 1515use Buzz \Message \RequestInterface ;
1616
1717/**
18+ * Transform PHP array to API array
19+ *
20+ * PHP array square brackets does not play nice with remote API,
21+ * which expects just the key name, without brackets.
22+ *
23+ * Transforms: foo[0]=xxx&foo[1]=yyy" to "foo=xxx&foo=yyy"
24+ *
1825 * @author Alexandru G. <alex@gentle.ro>
1926 */
20- class RequestListener implements ListenerInterface
27+ class NormalizeArrayListener implements ListenerInterface
2128{
2229 /**
2330 * {@inheritDoc}
2431 */
2532 public function getName ()
2633 {
27- return 'request ' ;
34+ return 'normalize_array ' ;
2835 }
2936
3037 /**
Original file line number Diff line number Diff line change 22
33namespace Bitbucket \Tests \API \Http \Listener ;
44
5- use Bitbucket \API \Http \Listener \RequestListener ;
5+ use Bitbucket \API \Http \Listener \NormalizeArrayListener ;
66use Bitbucket \Tests \API as Tests ;
77use Buzz \Message \Request ;
88
99/**
1010 * @author Alexandru G. <alex@gentle.ro>
1111 */
12- class RequestListenerTest extends Tests \TestCase
12+ class NormalizeArrayListenerTest extends Tests \TestCase
1313{
1414 public function testPHPArrayToApiArrayConversion ()
1515 {
16- $ listener = new RequestListener ();
16+ $ listener = new NormalizeArrayListener ();
1717 $ request = new Request ('POST ' , '/dummy ' );
1818
1919 $ request ->setContent (
You can’t perform that action at this time.
0 commit comments