Code Duplication    Length = 28-29 lines in 2 locations

tests/Unit/Collector/StackPluginTest.php 2 locations

@@ 104-131 (lines=28) @@
101
        });
102
    }
103
104
    public function testOnFulfilled()
105
    {
106
        //Capture the current stack
107
        $currentStack = null;
108
        $this->collector
109
            ->method('addStack')
110
            ->with($this->callback(function (Stack $stack) use (&$currentStack) {
111
                $currentStack = $stack;
112
113
                return true;
114
            }))
115
        ;
116
        $this->collector
117
            ->expects($this->once())
118
            ->method('deactivateStack')
119
        ;
120
121
        $next = function () {
122
            return new FulfilledPromise($this->response);
123
        };
124
125
        $promise = $this->subject->handleRequest($this->request, $next, function () {
126
        });
127
128
        $this->assertEquals($this->response, $promise->wait());
129
        $this->assertInstanceOf(Stack::class, $currentStack);
130
        $this->assertEquals('FormattedResponse', $currentStack->getResponse());
131
    }
132
133
    /**
134
     * @expectedException \Exception
@@ 136-164 (lines=29) @@
133
    /**
134
     * @expectedException \Exception
135
     */
136
    public function testOnRejected()
137
    {
138
        //Capture the current stack
139
        $currentStack = null;
140
        $this->collector
141
            ->method('addStack')
142
            ->with($this->callback(function (Stack $stack) use (&$currentStack) {
143
                $currentStack = $stack;
144
145
                return true;
146
            }))
147
        ;
148
        $this->collector
149
            ->expects($this->once())
150
            ->method('deactivateStack')
151
        ;
152
153
        $next = function () {
154
            return new RejectedPromise($this->exception);
155
        };
156
157
        $promise = $this->subject->handleRequest($this->request, $next, function () {
158
        });
159
160
        $this->assertEquals($this->exception, $promise->wait());
161
        $this->assertInstanceOf(Stack::class, $currentStack);
162
        $this->assertEquals('FormattedException', $currentStack->getResponse());
163
        $this->assertTrue($currentStack->isFailed());
164
    }
165
166
    /**
167
     * @expectedException \Exception