1: <?php
2:
3: namespace Alchemy\tests;
4: use Alchemy\util\promise\Signal;
5:
6:
7: class SignalTest extends BaseTest {
8: public function testSourceForwarding() {
9:
10: $this->expectsCallback($this->exactly(4))
11: ->will($this->onConsecutiveCalls(null, null, 4, 5));
12: $signal = new Signal($this->fnCallback);
13:
14: $this->assertFalse($signal->check());
15: $this->assertSame(null, $signal());
16: $this->assertTrue($signal->check());
17: $this->assertSame(5, $signal());
18:
19:
20:
21:
22: $this->expectsCallback($this->exactly(2))
23: ->will($this->onConsecutiveCalls(null, 5));
24: $signal = new Signal($this->fnCallback);
25:
26: $this->expectsCallback($this->exactly(2))
27: ->will($this->onConsecutiveCalls(null, $signal, 7));
28: $signal = new Signal($this->fnCallback);
29:
30: $this->assertFalse($signal->check());
31: $this->assertSame(null, $signal());
32: $this->assertSame(5, $signal());
33: }
34: }