File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -318,6 +318,18 @@ public function getClient()
318318 }
319319
320320
321+ /**
322+ * @param string
323+ * @return Api
324+ */
325+ public function withUrl ($ url )
326+ {
327+ $ api = clone $ this ;
328+ $ api ->setUrl ($ url );
329+ return $ api ;
330+ }
331+
332+
321333 /**
322334 * @param string
323335 * @return self
Original file line number Diff line number Diff line change @@ -29,12 +29,19 @@ test(function() {
2929 Assert::same ($ api , $ api ->setUrl ('url://test ' ));
3030 Assert::same ('url://test ' , $ api ->getUrl ());
3131
32+ $ clone = $ api ->withUrl ('url://cloned ' );
33+ Assert::notSame ($ api , $ clone );
34+ Assert::same ('url://test ' , $ api ->getUrl ());
35+ Assert::same ('url://cloned ' , $ clone ->getUrl ());
36+ Assert::same ($ api ->getClient (), $ clone ->getClient ());
37+
3238 $ token = new Milo \Github \OAuth \Token ('hash ' );
3339 Assert::null ($ api ->getToken ());
3440 Assert::same ($ api , $ api ->setToken ($ token ));
3541 Assert::same ($ token , $ api ->getToken ());
3642 $ api ->setToken (NULL );
3743 Assert::null ($ api ->getToken ());
44+
3845});
3946
4047
You can’t perform that action at this time.
0 commit comments