-
Notifications
You must be signed in to change notification settings - Fork 114
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 #562 from savinmikhail/issue-561
Issue 561
- Loading branch information
Showing
2 changed files
with
105 additions
and
1 deletion.
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
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,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], | ||
] | ||
]; | ||
} | ||
} |