Skip to content

Commit ef71af6

Browse files
committed
test: Helper
1 parent 3305688 commit ef71af6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

tests/HelperTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
namespace Ahc\Underscore\Tests;
4+
5+
use Ahc\Underscore\Helper;
6+
use Ahc\Underscore\Underscore as _;
7+
8+
class Stub
9+
{
10+
public function toArray()
11+
{
12+
return ['a', 'b', 'c'];
13+
}
14+
}
15+
16+
class Json implements \JsonSerializable
17+
{
18+
public function jsonSerialize()
19+
{
20+
return ['a' => 1, 'b' => 2, 'c' => 3];
21+
}
22+
}
23+
24+
class HelperTest extends \PHPUnit_Framework_TestCase
25+
{
26+
public function test_asArray()
27+
{
28+
$this->assertSame(['one'], Helper::asArray('one'));
29+
$this->assertSame([1, 2], Helper::asArray([1, 2]));
30+
$this->assertSame(['a', 'b', 'c'], Helper::asArray(new Stub));
31+
$this->assertSame(['a', 1, 'c', 3], Helper::asArray(new _(['a', 1, 'c', 3])));
32+
$this->assertSame(['a' => 1, 'b' => 2, 'c' => 3], Helper::asArray(new Json));
33+
}
34+
}

0 commit comments

Comments
 (0)