Code Duplication    Length = 27-29 lines in 2 locations

eZ/Publish/Core/Repository/SiteAccessAware/Tests/AbstractServiceTest.php 2 locations

@@ 134-162 (lines=29) @@
131
     * @param bool $return
132
     * @param int $languageArgumentIndex From 0 and up, so the array index on $arguments.
133
     */
134
    final public function testForLanguagesLookup($method, array $arguments, $return, $languageArgumentIndex, callable $callback = null)
135
    {
136
        $languages = ['eng-GB', 'eng-US'];
137
        $arguments[$languageArgumentIndex] = [];
138
139
        $expectedArguments = $this->setLanguagesLookupExpectedArguments($arguments, $languageArgumentIndex, $languages);
140
141
        $this->languageHelperMock
142
            ->expects($this->once())
143
            ->method('getPrioritizedLanguages')
144
            ->with([])
145
            ->willReturn($languages);
146
147
        $this->innerApiServiceMock
148
            ->expects($this->once())
149
            ->method($method)
150
            ->with(...$expectedArguments)
151
            ->willReturn($return);
152
153
        if ($callback instanceof Closure) {
154
            $callback->bindTo($this, static::class)(true);
155
        }
156
157
        $actualReturn = $this->service->$method(...$arguments);
158
159
        if ($return) {
160
            $this->assertTrue($actualReturn);
161
        }
162
    }
163
164
    /**
165
     * Method to be able to customize the logic for setting expected language argument during {@see testForLanguagesPassTrough()}.
@@ 190-216 (lines=27) @@
187
     * @param bool $return
188
     * @param int $languageArgumentIndex From 0 and up, so the array index on $arguments.
189
     */
190
    final public function testForLanguagesPassTrough($method, array $arguments, $return, $languageArgumentIndex, callable $callback = null)
191
    {
192
        $languages = ['eng-GB', 'eng-US'];
193
        $arguments = $this->setLanguagesPassTroughArguments($arguments, $languageArgumentIndex, $languages);
194
195
        $this->languageHelperMock
196
            ->expects($this->once())
197
            ->method('getPrioritizedLanguages')
198
            ->with($languages)
199
            ->willReturn($languages);
200
201
        $this->innerApiServiceMock
202
            ->expects($this->once())
203
            ->method($method)
204
            ->with(...$arguments)
205
            ->willReturn($return);
206
207
        if ($callback instanceof Closure) {
208
            $callback->bindTo($this, static::class)(false);
209
        }
210
211
        $actualReturn = $this->service->$method(...$arguments);
212
213
        if ($return) {
214
            $this->assertTrue($actualReturn);
215
        }
216
    }
217
}
218