/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new UserCreate($fxt); $obj->setConfig('dataFormat', 'array'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // No user id should fail $caught = false; try { $rsp = $obj->callApiWithParams(array('UserPassword' => 'phpsdkpassword', 'Email' => '*****@*****.**', 'CustomerEmail' => '*****@*****.**')); } catch (\exception $e) { $caught = true; $this->assertInstanceOf('MyAllocator\\phpsdk\\src\\Exception\\ApiException', $e); } if (!$caught) { $this->fail('should have thrown an exception'); } // Successful call with optional parameters $rsp = $obj->callApiWithParams(array('UserId' => 'phpsdkuser', 'UserPassword' => 'asfjksjkfsd', 'Email' => '*****@*****.**', 'CustomerEmail' => '*****@*****.**', 'CustomerFirstName' => 'Bob', 'CustomerLastName' => 'Smith', 'SendWelcome' => 0)); $this->assertTrue(isset($rsp['response']['body']['UserIdExists'])); $this->assertEquals($rsp['response']['body']['UserIdExists'], 'false'); $this->assertTrue(isset($rsp['response']['body']['Success'])); $this->assertEquals($rsp['response']['body']['Success'], 'true'); }
/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new UserCreate($fxt); $obj->setConfig('dataFormat', 'xml'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } $auth = $fxt['auth']; $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <UserCreate>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n </Auth>\n <UserId>phpsdkuser8</UserId>\n <UserPassword>asfjksjkfsd</UserPassword>\n <Email>phpsdkuser8@phpsdk.com</Email>\n <CustomerEmail>phpsdkuser8@phpsdk.com</CustomerEmail>\n <CustomerFirstName>Bob</CustomerFirstName>\n <CustomerLastName>Smith</CustomerLastName>\n <SendWelcome>0</SendWelcome>\n </UserCreate>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); }