1<?php
2
3namespace React\Promise;
4
5class FunctionRejectTest extends TestCase
6{
7    /** @test */
8    public function shouldRejectAnImmediateValue()
9    {
10        $expected = 123;
11
12        $mock = $this->createCallableMock();
13        $mock
14            ->expects($this->once())
15            ->method('__invoke')
16            ->with($this->identicalTo($expected));
17
18        reject($expected)
19            ->then(
20                $this->expectCallableNever(),
21                $mock
22            );
23    }
24
25    /** @test */
26    public function shouldRejectAFulfilledPromise()
27    {
28        $expected = 123;
29
30        $resolved = new FulfilledPromise($expected);
31
32        $mock = $this->createCallableMock();
33        $mock
34            ->expects($this->once())
35            ->method('__invoke')
36            ->with($this->identicalTo($expected));
37
38        reject($resolved)
39            ->then(
40                $this->expectCallableNever(),
41                $mock
42            );
43    }
44
45    /** @test */
46    public function shouldRejectARejectedPromise()
47    {
48        $expected = 123;
49
50        $resolved = new RejectedPromise($expected);
51
52        $mock = $this->createCallableMock();
53        $mock
54            ->expects($this->once())
55            ->method('__invoke')
56            ->with($this->identicalTo($expected));
57
58        reject($resolved)
59            ->then(
60                $this->expectCallableNever(),
61                $mock
62            );
63    }
64}
65