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 DeckTraitTest extends TestCase |
||
| 13 | { |
||
| 14 | // /** |
||
| 15 | // * Construct object and verify that the object is instance of class |
||
| 16 | // */ |
||
| 17 | public function testCreateObjectPokerSquares() |
||
| 18 | { |
||
| 19 | $pokersquares = new PokerSquares(); |
||
| 20 | $this->assertInstanceOf("\Joki20\Http\Controllers\PokerSquares", $pokersquares); |
||
| 21 | } |
||
| 22 | |||
| 23 | public function testTraitDeckName() |
||
| 24 | { |
||
| 25 | $pokersquares = new PokerSquares(); |
||
| 26 | |||
| 27 | $exp = strlen($pokersquares->name()); |
||
| 28 | $this->assertEquals($exp, 265); |
||
| 29 | } |
||
| 30 | |||
| 31 | public function testTraitDeckDeckSize() |
||
| 32 | { |
||
| 33 | $pokersquares = new PokerSquares(); |
||
| 34 | |||
| 35 | $exp = $pokersquares->deckSize(['<div class="card rank08C">8 <br/> ♣</div>','<div class="card rank09C">9 <br/> ♣</div>',]); |
||
| 36 | $this->assertEquals($exp, 2); |
||
| 37 | } |
||
| 38 | |||
| 39 | public function testTraitDeckReturnDeck() |
||
| 40 | { |
||
| 41 | $pokersquares = new PokerSquares(); |
||
| 42 | |||
| 43 | $exp = 52; |
||
| 44 | $res = count($pokersquares->returnDeck()); |
||
| 45 | $this->assertEquals($exp, $res); |
||
| 46 | } |
||
| 47 | } |
||
| 48 |