Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
1 | <?php |
||
12 | class MinkContext extends KFMinkContext |
||
13 | { |
||
14 | /** |
||
15 | * Checks, that page contains specified text |
||
16 | * Example: Then I should see "Who is the Batman?" |
||
17 | * Example: And I should see "Who is the Batman?". |
||
18 | */ |
||
19 | View Code Duplication | public function assertPageContainsText($text, $timeout = 10000) |
|
27 | |||
28 | /** |
||
29 | * Checks, that page doesn't contain specified text |
||
30 | * Example: Then I should not see "Batman is Bruce Wayne" |
||
31 | * Example: And I should not see "Batman is Bruce Wayne". |
||
32 | */ |
||
33 | View Code Duplication | public function assertPageNotContainsText($text, $timeout = 10000) |
|
41 | |||
42 | /** |
||
43 | * Checks, that element with specified CSS contains specified text |
||
44 | * Example: Then I should see "Batman" in the "heroes_list" element |
||
45 | * Example: And I should see "Batman" in the "heroes_list" element. |
||
46 | */ |
||
47 | public function assertElementContainsText($element, $text, $timeout = 10000) |
||
68 | |||
69 | /** |
||
70 | * @param Element $page |
||
71 | * @param float|int $timeout |
||
72 | */ |
||
73 | public function assertPageAddress($page, $timeout = 10000) |
||
85 | |||
86 | /** |
||
87 | * Try to find value in element and retry for a given time. |
||
88 | * |
||
89 | * @param Element $element |
||
90 | * @param string $value |
||
91 | * @param int $timeout |
||
92 | */ |
||
93 | protected function findOrRetry(Element $element, $value, $timeout = 10000) |
||
111 | } |
||
112 |