Completed
Push — master ( 9672ef...b72795 )
by Ivannis Suárez
02:30
created

ObservableResolverTestCase   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 60
Duplicated Lines 76.67 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 1
cbo 2
dl 46
loc 60
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A testResolve() 15 15 1
A testReject() 16 16 1
A testNotify() 15 15 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 Test Case class.
15
 *
16
 * @author Karel Osorio Ramírez <[email protected]>
17
 */
18
abstract class ObservableResolverTestCase extends ResolverTestCase
19
{
20
    /**
21
     * Test resolve.
22
     */
23 View Code Duplication
    public function testResolve()
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...
24
    {
25
        $this
26
            ->given(
27
                $resolveCallback = $this->delegateMockWithReturn('bar'),
28
                /** @var \Cubiche\Core\Async\Promise\ObservableResolver $resolver */
29
                $resolver = $this->newTestedInstance($resolveCallback)
30
            )
31
            ->when($resolver->resolve('foo'))
32
            ->then()
33
                ->delegateCall($resolveCallback)
34
                    ->withArguments('foo')
35
                    ->once()
36
        ;
37
    }
38
39
    /**
40
     * Test reject.
41
     */
42 View Code Duplication
    public function testReject()
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...
43
    {
44
        $this
45
            ->given(
46
                $reason = new \Exception(),
47
                $rejectCallback = $this->delegateMock(),
48
                /** @var \Cubiche\Core\Async\Promise\ObservableResolver $resolver */
49
                $resolver = $this->newTestedInstance(null, $rejectCallback)
50
            )
51
            ->when($resolver->reject($reason))
52
            ->then()
53
                ->delegateCall($rejectCallback)
54
                    ->withArguments($reason)
55
                    ->once()
56
        ;
57
    }
58
59
    /**
60
     * Test notify.
61
     */
62 View Code Duplication
    public function testNotify()
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...
63
    {
64
        $this
65
            ->given(
66
                $notifyCallback = $this->delegateMock(),
67
                /** @var \Cubiche\Core\Async\Promise\ObservableResolver $resolver */
68
                $resolver = $this->newTestedInstance(null, null, $notifyCallback)
69
            )
70
            ->when($resolver->notify('foo'))
71
            ->then()
72
                ->delegateCall($notifyCallback)
73
                    ->withArguments('foo')
74
                    ->once()
75
        ;
76
    }
77
}
78