Code Duplication    Length = 19-19 lines in 2 locations

tests/API/BridgeTest.php 1 location

@@ 99-117 (lines=19) @@
96
        $this->assertEquals('foobar', $results->getNavigation()->getName());
97
    }
98
99
    public function testMultipleFailingCalls()
100
    {
101
        $bridge = Phake::partialMock('GroupByInc\API\Bridge', self::CLIENT_KEY, self::HOST, self::PORT);
102
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 0)
103
            ->thenThrow(new Exception('the request failed!'));
104
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 1)
105
            ->thenThrow(new Exception('the request failed!'));
106
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 2)
107
            ->thenThrow(new Exception('the request failed!'));
108
109
        $query = new Query();
110
        /** @var Bridge $bridge */
111
        try {
112
            $bridge->search($query);
113
            $this->fail('expected a "retry failed" exceptions but got none');
114
        } catch (Exception $e) {
115
            $this->assertTrue(StringUtils::endsWith($e->getMessage(), 'failed after ' . AbstractBridge::MAX_TRIES . ' tries'));
116
        }
117
    }
118
119
    public function testSomeFailingCalls()
120
    {

tests/API/CloudBridgeTest.php 1 location

@@ 98-116 (lines=19) @@
95
        $this->assertEquals('foobar', $results->getNavigation()->getName());
96
    }
97
98
    public function testMultipleFailingCalls()
99
    {
100
        $bridge = Phake::partialMock('GroupByInc\API\CloudBridge', self::CLIENT_KEY, self::DOMAIN);
101
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 0)
102
            ->thenThrow(new Exception('the request failed!'));
103
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 1)
104
            ->thenThrow(new Exception('the request failed!'));
105
        Phake::when($bridge)->execute(self::SEARCH_URL, self::TEST_QUERY, 2)
106
            ->thenThrow(new Exception('the request failed!'));
107
108
        $query = new Query();
109
        /** @var CloudBridge $bridge */
110
        try {
111
            $bridge->search($query);
112
            $this->fail('expected a "retry failed" exceptions but got none');
113
        } catch (Exception $e) {
114
            $this->assertTrue(StringUtils::endsWith($e->getMessage(), 'failed after ' . AbstractBridge::MAX_TRIES . ' tries'));
115
        }
116
    }
117
118
    public function testSomeFailingCalls()
119
    {