ObservableResolverTests::testNotify()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
1
<?php
2
3
/**
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
namespace Cubiche\Core\Async\Tests\Units\Promise;
12
13
/**
14
 * Observable Resolver Tests class.
15
 *
16
 * @author Karel Osorio Ramírez <[email protected]>
17
 */
18
class ObservableResolverTests extends ObservableResolverTestCase
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function testResolve()
24
    {
25
        parent::testResolve();
26
27
        $this->innerFailureTest(function (callable $resolveCallback, callable $rejectCallback) {
28
            /** @var \Cubiche\Core\Async\Promise\ObservableResolver $resolver */
29
            $resolver = $this->newTestedInstance($resolveCallback, $rejectCallback);
30
            $resolver->resolve();
31
        });
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function testNotify()
38
    {
39
        parent::testNotify();
40
41
        $this->innerFailureTest(function (callable $notifyCallback, callable $rejectCallback) {
42
            /** @var \Cubiche\Core\Async\Promise\ObservableResolver $resolver */
43
            $resolver = $this->newTestedInstance(null, $rejectCallback, $notifyCallback);
44
            $resolver->notify();
45
        });
46
    }
47
48
    /**
49
     * @param callable $when
50
     */
51 View Code Duplication
    protected function innerFailureTest(callable $when)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
52
    {
53
        $this
54
            ->given(
55
                $reason = new \Exception(),
56
                $callback = $this->delegateMockWithException($reason),
57
                $rejectCallback = $this->delegateMock()
58
            )
59
            ->when($when($callback, $rejectCallback))
60
                ->then()
61
                ->delegateCall($rejectCallback)
62
                    ->withArguments($reason)
63
                    ->once()
64
            ;
65
    }
66
}
67