Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 561 #562

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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],
]
];
}
}