-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added where to ZohoManager module
- Loading branch information
Showing
5 changed files
with
129 additions
and
74 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
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 |
---|---|---|
|
@@ -2,10 +2,11 @@ | |
|
||
namespace Asciisd\Zoho\Tests\Integration; | ||
|
||
use Asciisd\Zoho\Facades\ZohoManager; | ||
use Asciisd\Zoho\ZohoModule; | ||
use zcrmsdk\crm\crud\ZCRMModule; | ||
use zcrmsdk\crm\crud\ZCRMRecord; | ||
use Asciisd\Zoho\CriteriaBuilder; | ||
use Asciisd\Zoho\Facades\ZohoManager; | ||
use zcrmsdk\crm\exception\ZCRMException; | ||
|
||
class ZohoModuleTest extends IntegrationTestCase | ||
|
@@ -15,123 +16,123 @@ class ZohoModuleTest extends IntegrationTestCase | |
private $client; | ||
private $module; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->client = $this->getClient(); | ||
$this->module = $this->client->useModule('Leads'); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_get_all_modules() | ||
{ | ||
public function it_can_get_all_modules() { | ||
$leads = $this->client->getAllModules(); | ||
|
||
self::assertInstanceOf(ZCRMModule::class, $leads[0]); | ||
} | ||
|
||
/** @test */ | ||
public function is_can_get_module_by_name() | ||
{ | ||
public function is_can_get_module_by_name() { | ||
$leads = $this->client->useModule(); | ||
|
||
self::assertInstanceOf(ZohoModule::class, $leads); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_instantiate_a_record_with_id() | ||
{ | ||
public function it_can_instantiate_a_record_with_id() { | ||
$record = $this->module->getRecordInstance(self::LEAD_ID_FOR_TEST); | ||
self::assertInstanceOf(ZCRMRecord::class, $record); | ||
self::assertEquals('Leads', $record->getModuleApiName()); | ||
self::assertEquals(self::LEAD_ID_FOR_TEST, $record->getEntityId()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_instantiate_a_module_with_api_name() | ||
{ | ||
public function it_can_instantiate_a_module_with_api_name() { | ||
$module = $this->module->getModuleInstance(); | ||
self::assertInstanceOf(ZCRMModule::class, $module); | ||
self::assertEquals('Leads', $module->getAPIName()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_get_records_for_given_module_api_name() | ||
{ | ||
public function it_can_get_records_for_given_module_api_name() { | ||
$records = $this->module->getRecords(); | ||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_get_record_by_module_api_name_and_record_id() | ||
{ | ||
public function it_can_get_record_by_module_api_name_and_record_id() { | ||
$record = $this->module->getRecord(self::LEAD_ID_FOR_TEST); | ||
self::assertInstanceOf(ZCRMRecord::class, $record); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_for_word_on_specific_module() | ||
{ | ||
public function it_can_search_for_word_on_specific_module() { | ||
$records = $this->module->searchRecordsByWord('Amr Ahmed'); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, end($records)); | ||
self::assertEquals(self::LEAD_ID_FOR_TEST, end($records)->getEntityId()); | ||
self::assertEquals(self::LEAD_ID_FOR_TEST, | ||
end($records)->getEntityId()); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_for_phone_on_specific_module() | ||
{ | ||
public function it_can_search_for_phone_on_specific_module() { | ||
$records = $this->module->searchRecordsByPhone('01011441444'); | ||
|
||
dump($records->getData()); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('01011441444', $records[0]->getFieldValue('Phone')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_for_email_on_specific_module() | ||
{ | ||
public function it_can_search_for_email_on_specific_module() { | ||
$records = $this->module->searchRecordsByEmail('[email protected]'); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('[email protected]', $records[0]->getFieldValue('Email')); | ||
self::assertEquals('[email protected]', | ||
$records[0]->getFieldValue('Email')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_by_criteria() { | ||
$records = | ||
$this->module->searchRecordsByCriteria("(City:equals:Al Wasitah) and (State:equals:Al Fayyum)"); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('[email protected]', | ||
$records[0]->getFieldValue('Email')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_by_criteria() | ||
{ | ||
$records = $this->module->searchRecordsByCriteria("(City:equals:Al Wasitah) and (State:equals:Al Fayyum)"); | ||
function it_can_search_by_criteria_builder() { | ||
$records = | ||
ZohoManager::useModule('Contacts')->search( | ||
CriteriaBuilder::where('City', 'Al Wasitah') | ||
->andWhere('State', 'Al Fayyum') | ||
); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('[email protected]', $records[0]->getFieldValue('Email')); | ||
self::assertEquals('[email protected]', | ||
$records[0]->getFieldValue('Email')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_by_field_name() | ||
{ | ||
public function it_can_search_by_field_name() { | ||
$records = $this->module->where('City', 'Al Wasitah')->search(); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('[email protected]', $records[0]->getFieldValue('Email')); | ||
self::assertEquals('[email protected]', | ||
$records[0]->getFieldValue('Email')); | ||
} | ||
|
||
/** @test */ | ||
public function it_can_search_with_multiple_criteria() | ||
{ | ||
public function it_can_search_with_multiple_criteria() { | ||
$records = $this->module | ||
->where('City', 'Al Wasitah') | ||
->andWhere('State', 'Al Fayyum') | ||
->search(); | ||
|
||
self::assertInstanceOf(ZCRMRecord::class, $records[0]); | ||
self::assertEquals('[email protected]', $records[0]->getFieldValue('Email')); | ||
self::assertEquals('[email protected]', | ||
$records[0]->getFieldValue('Email')); | ||
} | ||
|
||
/** @test | ||
* @throws ZCRMException | ||
*/ | ||
public function it_can_create_new_record() | ||
{ | ||
public function it_can_create_new_record() { | ||
$lead = $this->module->getRecordInstance(); | ||
|
||
$lead->setFieldValue('First_Name', 'Amr'); | ||
|
@@ -152,8 +153,7 @@ public function it_can_create_new_record() | |
/** @test | ||
* @throws ZCRMException | ||
*/ | ||
public function it_can_update_records() | ||
{ | ||
public function it_can_update_records() { | ||
$lead = $this->module->getRecord('3582074000002383003'); | ||
|
||
$lead->setFieldValue('Last_Name', 'Ahmed'); | ||
|
@@ -167,4 +167,11 @@ public function it_can_fetch_nested_data_with_module() { | |
$contacts = ZohoManager::useModule('Contacts'); | ||
$contacts->getAllModules(); | ||
} | ||
|
||
protected function setUp(): void { | ||
parent::setUp(); | ||
|
||
$this->client = $this->getClient(); | ||
$this->module = $this->client->useModule('Leads'); | ||
} | ||
} |