From a219d9b1f0e915a88fa6c0eeb1dcaddda1df617a Mon Sep 17 00:00:00 2001 From: Tim Mallezie Date: Mon, 18 May 2015 08:22:56 +0200 Subject: [PATCH] Add OpenID API with tests --- api/v3/OpenID.php | 80 +++++++++++++++++++++++++ tests/phpunit/api/v3/OpenIDTest.php | 90 +++++++++++++++++++++++++++++ 2 files changed, 170 insertions(+) create mode 100644 api/v3/OpenID.php create mode 100644 tests/phpunit/api/v3/OpenIDTest.php diff --git a/api/v3/OpenID.php b/api/v3/OpenID.php new file mode 100644 index 0000000000..20af3dbef9 --- /dev/null +++ b/api/v3/OpenID.php @@ -0,0 +1,80 @@ +useTransaction(TRUE); + + $this->_entity = 'openID'; + $this->_contactID = $this->organizationCreate(); + $this->params = array( + 'contact_id' => $this->_contactID, + 'name' => 'My OpenID handle', + 'location_type_id' => 1, + ); + } + + public function testCreateOpenID() { + $result = $this->callAPIAndDocument($this->_entity, 'create', $this->params, __FUNCTION__, __FILE__); + $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); + $this->getAndCheck($this->params, $result['id'], $this->_entity); + $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); + } + + public function testGetOpenID() { + $result = $this->callAPISuccess($this->_entity, 'create', $this->params); + $result = $this->callAPIAndDocument($this->_entity, 'get', $this->params, __FUNCTION__, __FILE__); + $this->assertEquals(1, $result['count'], 'In line ' . __LINE__); + $this->assertNotNull($result['values'][$result['id']]['id'], 'In line ' . __LINE__); + $this->callAPISuccess($this->_entity, 'delete', array('id' => $result['id'])); + } + + public function testDeleteOpenID() { + $result = $this->callAPISuccess($this->_entity, 'create', $this->params); + $deleteParams = array('id' => $result['id']); + $result = $this->callAPIAndDocument($this->_entity, 'delete', $deleteParams, __FUNCTION__, __FILE__); + $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); + $this->assertEquals(0, $checkDeleted['count'], 'In line ' . __LINE__); + } + + public function testDeleteOpenIDInvalid() { + $result = $this->callAPISuccess($this->_entity, 'create', $this->params); + $deleteParams = array('id' => 600); + $result = $this->callAPIFailure($this->_entity, 'delete', $deleteParams); + $checkDeleted = $this->callAPISuccess($this->_entity, 'get', array()); + $this->assertEquals(1, $checkDeleted['count'], 'In line ' . __LINE__); + } + +} -- 2.25.1