Code Duplication    Length = 14-15 lines in 2 locations

src/SilverStripe/BehatExtension/Context/EmailContext.php 2 locations

@@ 161-175 (lines=15) @@
158
    /**
159
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)"$/
160
     */
161
    public function iGoToInTheEmailTo($linkSelector, $direction, $email)
162
    {
163
        $to = ($direction == 'to') ? $email : null;
164
        $from = ($direction == 'from') ? $email : null;
165
        $match = $this->mailer->findEmail($to, $from);
166
        assertNotNull($match);
167
168
        $crawler = new Crawler($match->Content);
169
        $linkEl = $crawler->selectLink($linkSelector);
170
        assertNotNull($linkEl);
171
        $link = $linkEl->attr('href');
172
        assertNotNull($link);
173
        
174
        return new Step\When(sprintf('I go to "%s"', $link));
175
    }
176
177
    /**
178
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)" titled "([^"]*)"$/
@@ 180-193 (lines=14) @@
177
    /**
178
     * @When /^I click on the "([^"]*)" link in the email (to|from) "([^"]*)" titled "([^"]*)"$/
179
     */
180
    public function iGoToInTheEmailToTitled($linkSelector, $direction, $email, $title)
181
    {
182
        $to = ($direction == 'to') ? $email : null;
183
        $from = ($direction == 'from') ? $email : null;
184
        $match = $this->mailer->findEmail($to, $from, $title);
185
        assertNotNull($match);
186
187
        $crawler = new Crawler($match->Content);
188
        $linkEl = $crawler->selectLink($linkSelector);
189
        assertNotNull($linkEl);
190
        $link = $linkEl->attr('href');
191
        assertNotNull($link);
192
        return new Step\When(sprintf('I go to "%s"', $link));
193
    }
194
    
195
    /**
196
     * Assumes an email has been identified by a previous step,