Code Duplication    Length = 18-18 lines in 2 locations

tests/API/BridgeTest.php 1 location

@@ 24-41 (lines=18) @@
21
    const TEST_QUERY = '{"clientKey":"randomkey","sort":[],"fields":[],"orFields":[],"refinements":[],"customUrlParams":[],"skip":0,"pageSize":10,"pruneRefinements":true,"wildcardSearchEnabled":false}';
22
    const TEST_RESPONSE = '{"query":"foobar","pageInfo":{"recordStart":14,"recordEnd":23}}';
23
24
    public function testErroneousStatusCode()
25
    {
26
        $bridge = Phake::partialMock('GroupByInc\API\Bridge', self::CLIENT_KEY, self::HOST, self::PORT);
27
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 0)
28
            ->thenReturn(new Response('{"foo":"bar"}', 'Status 400', Request::post('')));
29
30
        $query = new Query();
31
        try {
32
            /** @var Bridge $bridge */
33
            $bridge->search($query);
34
            $this->fail("Should have thrown exception here");
35
        } catch (RuntimeException $e) {
36
            if (strpos($e->getMessage(), '404 Not Found') !== false) {
37
                $this->fail("Expected status code 400, found 404");
38
            }
39
            // Should throw exception
40
        }
41
    }
42
43
    public function testErrorOnReturnBinary()
44
    {

tests/API/CloudBridgeTest.php 1 location

@@ 23-40 (lines=18) @@
20
    const TEST_QUERY = '{"clientKey":"randomkey","sort":[],"fields":[],"orFields":[],"refinements":[],"customUrlParams":[],"skip":0,"pageSize":10,"pruneRefinements":true,"wildcardSearchEnabled":false}';
21
    const TEST_RESPONSE = '{"query":"foobar","pageInfo":{"recordStart":14,"recordEnd":23}}';
22
23
    public function testErroneousStatusCode()
24
    {
25
        $bridge = Phake::partialMock('GroupByInc\API\CloudBridge', self::CLIENT_KEY, self::DOMAIN);
26
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 0)
27
            ->thenReturn(new Response('{"foo":"bar"}', 'Status 400', Request::post('')));
28
29
        $query = new Query();
30
        try {
31
            /** @var CloudBridge $bridge */
32
            $bridge->search($query);
33
            $this->fail("Should have thrown exception here");
34
        } catch (RuntimeException $e) {
35
            if (strpos($e->getMessage(), '404 Not Found') !== false) {
36
                $this->fail("Expected status code 400, found 404");
37
            }
38
            // Should throw exception
39
        }
40
    }
41
42
    public function testErrorOnReturnBinary()
43
    {