/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { $obj = new HelloWorld($fxt); $obj->setConfig('dataFormat', 'array'); $rsp = $obj->callApiWithParams($fxt['params']); $this->assertTrue(isset($rsp['response']['body']['hello'])); $this->assertEquals('world', $rsp['response']['body']['hello']); }
/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { $obj = new HelloWorld(); $obj->setConfig('dataFormat', 'xml'); $auth = $fxt['auth']; $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <HelloWorld>\n <Auth></Auth>\n <hello>world</hello>\n </HelloWorld>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); }
* the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS * IN THE SOFTWARE. */ /* * You may use require_once similar to below to autoload * the MyAllocator PHP SDK. Composer package install is * preferred. */ require_once dirname(__FILE__) . '/MyAllocator.php'; use MyAllocator\phpsdk\src\Api\HelloWorld; $params = array('Auth' => 'true', 'hello' => 'world'); $api = new HelloWorld(); $api->setConfig('dataFormat', 'array'); try { $rsp = $api->callApiWithParams($params); } catch (Exception $e) { $rsp = 'Oops: ' . $e->getMessage(); } var_dump($rsp);