Skip to content

Commit

Permalink
Merge pull request #562 from savinmikhail/issue-561
Browse files Browse the repository at this point in the history
Issue 561
  • Loading branch information
bessudnov authored Feb 5, 2025
2 parents 7cb14d6 + e366f84 commit 733e347
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/AmoCRM/Filters/EventsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ public function getEntityIds()
*/
public function setEntityIds($entityIds)
{
$this->entityIds = $entityIds;
$this->entityIds = $this->parseArrayOrNumberFilter($entityIds);

return $this;
}
Expand Down
104 changes: 104 additions & 0 deletions tests/Cases/AmoCRM/Filters/EventsFilterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?php

declare(strict_types=1);

namespace Cases\AmoCRM\Filters;

use AmoCRM\Filters\EventsFilter;
use PHPUnit\Framework\TestCase;

class EventsFilterTest extends TestCase
{
/**
* @var EventsFilter
*/
private $eventsFilter;

public function setUp(): void
{
$this->eventsFilter = new EventsFilter();
}

/**
* @dataProvider getValidArrayOrNumericFilter
*
* @param $entityIds
* @param $expected
*/
public function testValidEntityIds($entityIds, $expected)
{
$this->eventsFilter->setEntityIds($entityIds);
$this->assertEquals($expected, array_values($this->eventsFilter->getEntityIds()));
}

/**
* @dataProvider getInvalidArrayOrNumericFilter
*
* @param $entityIds
*/
public function testInvalidEntityIds($entityIds)
{
$this->eventsFilter->setEntityIds($entityIds);
$this->assertNull($this->eventsFilter->getEntityIds());
}

/**
* @return array
*/
public function getInvalidArrayOrNumericFilter() {
return [
[
-1,
],
[
[
-1,
-100
],
],
[
[
-100,
],
],
[
"hello"
],
[
[
true,
false
]
],
[
false
],
[
null
],
];
}

/**
* @return array
*/
public function getValidArrayOrNumericFilter() {
return [
[
0, [0],
],
[
100, [100],
],
[
"100", [100],
],
[
[1, 2, 3, 4], [1, 2, 3, 4],
],
[
[-1, 1, 2], [1 , 2],
]
];
}
}

0 comments on commit 733e347

Please sign in to comment.