Code Duplication    Length = 14-15 lines in 2 locations

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

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