Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Commit 83ba81e

Browse files
authored
Merge pull request #127 from kopecny-shockworks/master
Fixed CRM.Company.update
2 parents fae1e39 + 88f57fd commit 83ba81e

File tree

2 files changed

+55
-2
lines changed

2 files changed

+55
-2
lines changed

src/classes/crm/company/company.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,10 @@ public function update($bitrix24CompanyId, $fields = array())
6363
{
6464
$fullResult = $this->client->call(
6565
'crm.company.update',
66-
array('id' => $bitrix24CompanyId),
67-
array('fields' => $fields)
66+
array(
67+
'id' => $bitrix24CompanyId,
68+
'fields' => $fields,
69+
)
6870
);
6971
return $fullResult;
7072
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
<?php
2+
/*
3+
* This file is part of the bitrix24-php-sdk package.
4+
*
5+
* © Mesilov Maxim <mesilov.maxim@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Bitrix24\CRM;
11+
12+
use Bitrix24\CRM\Company;
13+
use Bitrix24\Contracts\iBitrix24;
14+
15+
16+
/**
17+
* @package Bitrix24
18+
*/
19+
class CompanyTest extends \PHPUnit_Framework_TestCase
20+
{
21+
public function testUpdateCallsClientWithIdAndFields()
22+
{
23+
$testId = \md5(\time());
24+
$testField = \md5($testId);
25+
$testFields = [
26+
$testField => \md5($testField),
27+
];
28+
29+
//silly mocking in PHPUnit 4.8
30+
$methods = array();
31+
$ref = new \ReflectionClass('Bitrix24\\Contracts\\iBitrix24');
32+
foreach ($ref->getMethods() as $method) {
33+
$methods[] = $method->getName();
34+
}
35+
$client = $this->getMockBuilder('Bitrix24\\Contracts\\iBitrix24')
36+
->setMethods($methods)
37+
->getMock();
38+
$client->expects($this->once())
39+
->method('call')
40+
->with(
41+
'crm.company.update',
42+
array(
43+
'id' => $testId,
44+
'fields' => $testFields,
45+
)
46+
);
47+
48+
$company = new Company($client);
49+
$company->update($testId, $testFields);
50+
}
51+
}

0 commit comments

Comments
 (0)