forked from jamesiarmes/php-ews
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding ability to delete item fields
- Loading branch information
Showing
18 changed files
with
201 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...recordings/jamesiarmes/PEWS/Test/APITest.testGetFolderByDisplayName with data set #0.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/APITest.testGetFolderByDisplayNameFail.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/APITest.testGetFolderByDistinguishedId.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
[{"statusCode":200,"headers":{"Cache-Control":["private"],"Transfer-Encoding":["chunked"],"Content-Type":["text\/xml; charset=utf-8"],"Server":["Microsoft-IIS\/7.5"],"Set-Cookie":["exchangecookie=14801a464dee4487940d347916088856; expires=Tue, 28-Feb-2017 10:42:26 GMT; path=\/; HttpOnly"],"X-AspNet-Version":["2.0.50727"],"Persistent-Auth":["true"],"X-Powered-By":["ASP.NET"],"Date":["Mon, 29 Feb 2016 10:42:26 GMT"]},"body":"<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"><s:Header><h:ServerVersionInfo MajorVersion=\"14\" MinorVersion=\"3\" MajorBuildNumber=\"195\" MinorBuildNumber=\"1\" Version=\"Exchange2010_SP2\" xmlns:h=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/types\" xmlns=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/types\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"\/><\/s:Header><s:Body xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\"><m:GetFolderResponse xmlns:m=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/messages\" xmlns:t=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/types\"><m:ResponseMessages><m:GetFolderResponseMessage ResponseClass=\"Success\"><m:ResponseCode>NoError<\/m:ResponseCode><m:Folders><t:CalendarFolder><t:FolderId Id=\"AQMkADhiZjhlMDZjLTc0MDItNDI5OQAtOTcyMC02M2U2NDZhZmI3MTMALgAAA6i8KDve4qpIkQ6MdHAyIZ4BAPkqvLM2ftlLgyCv9ALxwvYAAAIBDQAAAA==\" ChangeKey=\"AgAAABYAAAD5KryzNn7ZS4Mgr\/QC8cL2AABpp01c\"\/><t:DisplayName>Calendar<\/t:DisplayName><t:ChildFolderCount>1<\/t:ChildFolderCount><\/t:CalendarFolder><\/m:Folders><\/m:GetFolderResponseMessage><\/m:ResponseMessages><\/m:GetFolderResponse><\/s:Body><\/s:Envelope>"}] | ||
[{"statusCode":200,"headers":{"Cache-Control":["private"],"Transfer-Encoding":["chunked"],"Content-Type":["text\/xml; charset=utf-8"],"Server":["Microsoft-IIS\/8.0"],"request-id":["d2e6ea1b-4f3d-49ae-b9bc-965d13ebe851"],"X-CalculatedBETarget":["HE1PR0401MB1884.eurprd04.prod.outlook.com"],"X-BackEndHttpStatus":["200"],"Set-Cookie":["exchangecookie=0594fa42c17244f28526afecc478824d; expires=Sat, 06-May-2017 10:15:05 GMT; path=\/; HttpOnly"],"x-EwsHandler":["GetFolder"],"X-AspNet-Version":["4.0.30319"],"X-DiagInfo":["HE1PR0401MB1884"],"X-BEServer":["HE1PR0401MB1884"],"X-Powered-By":["ASP.NET"],"X-FEServer":["AM2PR07CA0032"],"Date":["Fri, 06 May 2016 10:15:05 GMT"]},"body":"<?xml version=\"1.0\" encoding=\"utf-8\"?><s:Envelope xmlns:s=\"http:\/\/schemas.xmlsoap.org\/soap\/envelope\/\"><s:Header><h:ServerVersionInfo MajorVersion=\"15\" MinorVersion=\"1\" MajorBuildNumber=\"485\" MinorBuildNumber=\"14\" Version=\"V2016_01_06\" xmlns:h=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/types\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\"\/><\/s:Header><s:Body><m:GetFolderResponse xmlns:m=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/messages\" xmlns:xsd=\"http:\/\/www.w3.org\/2001\/XMLSchema\" xmlns:xsi=\"http:\/\/www.w3.org\/2001\/XMLSchema-instance\" xmlns:t=\"http:\/\/schemas.microsoft.com\/exchange\/services\/2006\/types\"><m:ResponseMessages><m:GetFolderResponseMessage ResponseClass=\"Success\"><m:ResponseCode>NoError<\/m:ResponseCode><m:Folders><t:CalendarFolder><t:FolderId Id=\"AAMkAGRmOGJjZTc0LWQ0ZWUtNDliZC1hYjQ1LTkyODM1NjFhMGIzNwAuAAAAAAAdsEfFUCwSRaf4+E1agVdfAQA4JiVRwOF7SbQybW1zR3q0AAAAAAENAAA=\" ChangeKey=\"AgAAABYAAAA4JiVRwOF7SbQybW1zR3q0AAAAAAA3\"\/><t:DisplayName>Calendar<\/t:DisplayName><t:TotalCount>2<\/t:TotalCount><t:ChildFolderCount>3<\/t:ChildFolderCount><\/t:CalendarFolder><\/m:Folders><\/m:GetFolderResponseMessage><\/m:ResponseMessages><\/m:GetFolderResponse><\/s:Body><\/s:Envelope>"}] |
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/APITest.testListItemChanges with data set #0.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/Calendar/APITest.testDeleteCalendarItem.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/Calendar/APITest.testGetCalendarItems.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/Calendar/APITest.testListChanges.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/Calendar/APITest.testPickCalendar.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
Resources/recordings/jamesiarmes/PEWS/Test/Calendar/APITest.testUpdateCalendarItem.json
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?php | ||
|
||
use garethp\ews\Contacts\ContactsAPI as API; | ||
|
||
$api = API::withUsernameAndPassword('server', 'username', 'password'); | ||
|
||
$contact = $api->getContacts(); | ||
|
||
$api->updateContactItem($contact[0]->getItemId(), array( | ||
'deleteFields' => array ( | ||
'GivenName', | ||
'PhoneNumber:HomePhone' | ||
) | ||
)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
namespace garethp\ews\Test\Contacts; | ||
|
||
use garethp\ews\API\Type\ContactItemType; | ||
use garethp\ews\API\Type\ItemIdType; | ||
use PHPUnit_Framework_TestCase; | ||
use garethp\ews\Contacts\ContactsAPI as API; | ||
|
||
class ContactsAPI extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* @return \garethp\ews\Contacts\ContactsAPI | ||
*/ | ||
public function getClient() | ||
{ | ||
$mode = getenv('HttpPlayback'); | ||
if ($mode == false) { | ||
$mode = 'playback'; | ||
} | ||
|
||
$auth = [ | ||
'server' => 'server', | ||
'user' => 'user', | ||
'password' => 'password' | ||
]; | ||
|
||
if (is_file(getcwd() . '/Resources/auth.json')) { | ||
$auth = json_decode(file_get_contents(getcwd() . '/Resources/auth.json'), true); | ||
} | ||
|
||
$client = API::withUsernameAndPassword( | ||
$auth['server'], | ||
$auth['user'], | ||
$auth['password'], | ||
[ | ||
'httpPlayback' => [ | ||
'mode' => $mode, | ||
'recordFileName' => self::class . '.' . $this->getName() . '.json' | ||
] | ||
] | ||
); | ||
|
||
$testFolder = $client->getFolderByDisplayName('Test', $client->getFolderId()); | ||
$client->setFolderId($testFolder->getFolderId()); | ||
|
||
return $client; | ||
} | ||
|
||
public function testCreateContact() | ||
{ | ||
$api = $this->getClient(); | ||
|
||
$contact = $api->createContacts(array ( | ||
'GivenName' => 'John', | ||
'Surname' => 'Smith', | ||
'EmailAddresses' => array( | ||
'Entry' => array('Key' => 'EmailAddress1', '_value' => 'john.smith@gmail.com') | ||
), | ||
'PhoneNumbers' => array( | ||
'Entry' => array('Key' => 'HomePhone', '_value' => '000') | ||
) | ||
)); | ||
|
||
$this->assertArrayHasKey(0, $contact); | ||
|
||
$contact = $contact[0]; | ||
$this->assertInstanceOf(ItemIdType::class, $contact); | ||
|
||
$contact = $api->getContact($contact); | ||
$this->assertNotNull($contact); | ||
$this->assertEquals('John', $contact->getGivenName()); | ||
|
||
$api->deleteItems($contact->getItemId()); | ||
} | ||
|
||
public function testUpdateContact() | ||
{ | ||
$api = $this->getClient(); | ||
|
||
$contact = $api->createContacts(array ( | ||
'GivenName' => 'John', | ||
'Surname' => 'Smith', | ||
'EmailAddresses' => array( | ||
'Entry' => array('Key' => 'EmailAddress1', '_value' => 'john.smith@gmail.com') | ||
), | ||
'PhoneNumbers' => array( | ||
'Entry' => array('Key' => 'HomePhone', '_value' => '000') | ||
) | ||
)); | ||
|
||
$contact = $contact[0]; | ||
$api->updateContactItem($contact, array( | ||
'GivenName' => 'Jane', | ||
'EmailAddress:EmailAddress1' => array ( | ||
'EmailAddresses' => array ( | ||
'Entry' => array('Key' => 'EmailAddress1', '_value' => 'jane.smith@gmail.com') | ||
) | ||
), | ||
'PhoneNumber:HomePhone' => array ( | ||
'PhoneNumbers' => array ( | ||
'Entry' => array('Key' => 'HomePhone', '_value' => '111') | ||
) | ||
) | ||
)); | ||
|
||
$contact = $api->getContact($contact); | ||
$this->assertEquals('Jane', $contact->getGivenName()); | ||
$this->assertEquals('jane.smith@gmail.com', $contact->getEmailAddresses()->Entry); | ||
$this->assertEquals('111', $contact->getPhoneNumbers()->Entry); | ||
|
||
$api->deleteItems($contact->getItemId()); | ||
} | ||
} |