Code Duplication    Length = 14-15 lines in 2 locations

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

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