Skip to content

Commit 7dfc822

Browse files
committed
unit test for previous commit (crm.company.update fix)
1 parent aa07f6f commit 7dfc822

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<?php
2+
/*
3+
* This file is part of the bitrix24-php-sdk package.
4+
*
5+
* © Mesilov Maxim <[email protected]>
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+
* @package Bitrix24
17+
*/
18+
class CompanyTest extends \PHPUnit_Framework_TestCase
19+
{
20+
public function testUpdateCallsClientWithIdAndFields()
21+
{
22+
$testId = \md5(\time());
23+
$testField = \md5($testId);
24+
$testFields = [
25+
$testField => \md5($testField),
26+
];
27+
28+
//silly mocking in PHPUnit 4.8
29+
$methods = array();
30+
$ref = new \ReflectionClass(iBitrix24::class);
31+
foreach ($ref->getMethods() as $method) {
32+
$methods[] = $method->getName();
33+
}
34+
$client = $this->getMockBuilder(iBitrix24::class)
35+
->setMethods($methods)
36+
->getMock();
37+
$client->expects($this->once())
38+
->method('call')
39+
->with(
40+
'crm.company.update',
41+
array(
42+
'id' => $testId,
43+
'fields' => $testFields,
44+
)
45+
);
46+
47+
$company = new Company($client);
48+
$company->update($testId, $testFields);
49+
}
50+
}

0 commit comments

Comments
 (0)