Skip to content

Commit 43522a6

Browse files
committed
test(hom): test call/get
1 parent a8b34b7 commit 43522a6

File tree

1 file changed

+75
-0
lines changed

1 file changed

+75
-0
lines changed

tests/HigherOrderMessageTest.php

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the PHP-UNDERSCORE package.
5+
*
6+
* (c) Jitendra Adhikari <[email protected]>
7+
* <https://github.com/adhocore>
8+
*
9+
* Licensed under MIT license.
10+
*/
11+
12+
namespace Ahc\Underscore\Test;
13+
14+
use Ahc\Underscore\HigherOrderMessage;
15+
use PHPUnit\Framework\TestCase as TestCase;
16+
17+
/**
18+
* Auto generated by `phint test`
19+
*/
20+
class HigherOrderMessageTest extends TestCase
21+
{
22+
/**
23+
* @var HigherOrderMessage
24+
*/
25+
protected $hom1;
26+
27+
/**
28+
* @var HigherOrderMessage
29+
*/
30+
protected $hom2;
31+
32+
public function setUp()
33+
{
34+
parent::setUp();
35+
36+
$this->hom1 = new HigherOrderMessage(
37+
underscore([
38+
['a' => 1, 'b' => 2],
39+
]),
40+
'map'
41+
);
42+
43+
$this->hom2 = new HigherOrderMessage(
44+
underscore([
45+
new class {
46+
public $b = 'B';
47+
48+
public function a()
49+
{
50+
return 'A';
51+
}
52+
}
53+
]),
54+
'map'
55+
);
56+
}
57+
58+
public function test_call()
59+
{
60+
$actual = $this->hom2->a()->get();
61+
62+
$this->assertSame(['A'], $actual);
63+
}
64+
65+
public function test_get()
66+
{
67+
$actual = $this->hom1->b->get();
68+
69+
$this->assertSame([2], $actual);
70+
71+
$actual = $this->hom2->b->get();
72+
73+
$this->assertSame(['B'], $actual);
74+
}
75+
}

0 commit comments

Comments
 (0)