-
-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #342 from KarlsonComplete/add-support-for-operatin…
…g-timing add support for operating timing
- Loading branch information
Showing
3 changed files
with
84 additions
and
2 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
59 changes: 59 additions & 0 deletions
59
tests/Integration/OperatingTimingTest/OperatingTimingTest.php
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,59 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Bitrix24\SDK\Tests\Integration\OperatingTimingTest; | ||
|
||
use Bitrix24\SDK\Core\Batch; | ||
use Bitrix24\SDK\Services\CRM\Contact\Service\Contact; | ||
use Bitrix24\SDK\Tests\Integration\Fabric; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* Class OperatingTimingTest | ||
* | ||
* @package Bitrix24\SDK\Tests\Integration\OperatingTimingTest | ||
*/ | ||
class OperatingTimingTest extends TestCase | ||
{ | ||
protected Contact $contactService; | ||
protected Batch $batch; | ||
|
||
/** | ||
* @throws \Bitrix24\SDK\Core\Exceptions\TransportException | ||
* @throws \Bitrix24\SDK\Core\Exceptions\BaseException | ||
*/ | ||
public function testOperatingTiming(): void | ||
{ | ||
|
||
$timeStart = microtime(true); | ||
$contactsToUpdate = []; | ||
foreach ($this->contactService->batch->list([], ['>ID' => '12'], ['ID', 'PHONE'], 30000) as $contactList) { | ||
$contactsToUpdate[$contactList->ID] = [ | ||
'fields' => [ | ||
'PHONE' => [['ID' => $contactList->PHONE[0]['ID']]] | ||
], | ||
'params' => [], | ||
]; | ||
$contactListId[] = $contactList->ID; | ||
} | ||
foreach ($this->contactService->batch->update($contactsToUpdate) as $dealUpdateResult) { | ||
$logOperating[] = $dealUpdateResult->getResponseData()->getTime()->getOperating(); | ||
$logOperatingResetAt = $dealUpdateResult->getResponseData()->getTime()->getOperatingResetAt(); | ||
$sumOperating = array_sum($logOperating); | ||
echo "summa operating: " . $sumOperating . PHP_EOL; | ||
echo "operating rest at: " . $logOperatingResetAt . PHP_EOL; | ||
} | ||
$timeEnd = microtime(true); | ||
echo sprintf('batch query duration: %s seconds', round($timeEnd - $timeStart, 2)) . PHP_EOL; | ||
|
||
self::assertGreaterThanOrEqual(5, $contactListId); | ||
|
||
} | ||
|
||
public function setUp(): void | ||
{ | ||
$this->batch = Fabric::getBatchService(); | ||
$this->contactService = Fabric::getServiceBuilder()->getCRMScope()->contact(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -199,10 +199,11 @@ protected function generateContacts(int $contactsCount): array | |
'SECOND_NAME' => sprintf('second_%s', $i), | ||
'PHONE' => [ | ||
['VALUE' => sprintf('+7978%s', random_int(1000000, 9999999)), 'VALUE_TYPE' => 'MOBILE'], | ||
['VALUE' => implode("-", str_split(substr( sprintf('%s', microtime()), 2, -13), 2))], | ||
], | ||
'EMAIL' => [ | ||
/* 'EMAIL' => [ | ||
['VALUE' => sprintf('test-%[email protected]', random_int(1000000, 9999999)), 'VALUE_TYPE' => 'WORK'], | ||
], | ||
],*/ | ||
]; | ||
} | ||
|
||
|