/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new UserExists($fxt); $obj->setConfig('dataFormat', 'array'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // Exists by email (Omitting required UserId parameter) $caught = false; try { $rsp = $obj->callApiWithParams(array('CustomerEmail' => '*****@*****.**')); } catch (\exception $e) { $caught = true; $this->assertInstanceOf('MyAllocator\\phpsdk\\src\\Exception\\ApiException', $e); } if (!$caught) { $this->fail('Should have thrown an exception'); } // Exists by id $rsp = $obj->callApiWithParams(array('UserId' => 'phpsdkuser')); $this->assertTrue(isset($rsp['response']['body']['EmailExists'])); $this->assertTrue(isset($rsp['response']['body']['UserIdExists'])); // Exists by id and email $rsp = $obj->callApiWithParams(array('UserId' => 'phpsdkuser', 'CustomerEmail' => '*****@*****.**')); $this->assertTrue(isset($rsp['response']['body']['EmailExists'])); $this->assertTrue(isset($rsp['response']['body']['UserIdExists'])); }
/** * @author nathanhelenihi * @group api * @dataProvider fixtureAuthCfgObject */ public function testCallApi(array $fxt) { if (!$fxt['from_env']) { $this->markTestSkipped('Environment credentials not set.'); } $obj = new UserExists($fxt); $obj->setConfig('dataFormat', 'xml'); if (!$obj->isEnabled()) { $this->markTestSkipped('API is disabled!'); } // Exists by id $auth = $fxt['auth']; $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <UserExists>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n </Auth>\n <UserId>phpsdkuser</UserId>\n </UserExists>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); // Exists by id and email $auth = $fxt['auth']; $xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n <UserExists>\n <Auth>\n <VendorId>{$auth->vendorId}</VendorId>\n <VendorPassword>{$auth->vendorPassword}</VendorPassword>\n </Auth>\n <UserId>phpsdkuser</UserId>\n <CustomerEmail>phpsdkuser@phpsdk.com</CustomerEmail>\n </UserExists>\n "; $rsp = $obj->callApiWithParams($xml); $this->assertEquals(200, $rsp['response']['code']); $this->assertFalse(strpos($rsp['response']['body'], '<Errors>'), 'Response contains errors!'); }