Skip to content

Commit 2458071

Browse files
committed
Add tests for AbstractApi::isNotNull()
1 parent d2f08f1 commit 2458071

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

tests/Unit/Api/AbstractApiTest.php

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,44 @@
1414
*/
1515
class AbstractApiTest extends TestCase
1616
{
17+
/**
18+
* @test
19+
* @dataProvider getIsNotNullReturnsCorrectBooleanData
20+
*/
21+
public function testIsNotNullReturnsCorrectBoolean(bool $expected, $value)
22+
{
23+
$client = $this->createMock(Client::class);
24+
25+
$api = $this->getMockForAbstractClass(AbstractApi::class, [$client]);
26+
27+
$method = new ReflectionMethod($api, 'isNotNull');
28+
$method->setAccessible(true);
29+
30+
$this->assertSame($expected, $method->invoke($api, $value));
31+
}
32+
33+
public function getIsNotNullReturnsCorrectBooleanData()
34+
{
35+
return [
36+
[false, null],
37+
[false, false],
38+
[false, ''],
39+
[false, []],
40+
[true, true],
41+
[true, 0],
42+
[true, 1],
43+
[true, 0.0],
44+
[true, -0.0],
45+
[true, 0.5],
46+
[true, '0'],
47+
[true, 'string'],
48+
[true, [0]],
49+
[true, ['0']],
50+
[true, ['']],
51+
[true, new \stdClass],
52+
];
53+
}
54+
1755
/**
1856
* @covers \Redmine\Api\AbstractApi
1957
* @test

0 commit comments

Comments
 (0)