|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
View Code Duplication |
class stringsTest extends PHPUnit_Framework_TestCase |
|
|
|
|
|
|
4
|
|
|
{ |
|
5
|
|
|
private $e; |
|
6
|
|
|
|
|
7
|
|
|
public function setUp() |
|
8
|
|
|
{ |
|
9
|
|
|
|
|
10
|
|
|
$this->e = new strings(); |
|
11
|
|
|
} |
|
12
|
|
|
|
|
13
|
|
|
public function tearDown() { |
|
14
|
|
|
$this->e = NULL; |
|
15
|
|
|
} |
|
16
|
|
|
|
|
17
|
|
|
public function test_struname() { |
|
|
|
|
|
|
18
|
|
|
// Happy path |
|
19
|
|
|
$this->assertEquals($this->e->struname("this"), "This"); |
|
|
|
|
|
|
20
|
|
|
$this->assertEquals($this->e->struname("1this"), "1this"); |
|
|
|
|
|
|
21
|
|
|
$this->assertEquals($this->e->struname("This"), "This"); |
|
|
|
|
|
|
22
|
|
|
$this->assertEquals($this->e->struname("This "), "This"); |
|
|
|
|
|
|
23
|
|
|
$this->assertEquals($this->e->struname("This_"), "This"); |
|
|
|
|
|
|
24
|
|
|
|
|
25
|
|
|
// Sad Path |
|
26
|
|
|
$this->assertNotEquals($this->e->struname("This "), "This "); |
|
|
|
|
|
|
27
|
|
|
$this->assertNotEquals($this->e->struname("This_"), "This_"); |
|
|
|
|
|
|
28
|
|
|
$this->assertNotEquals($this->e->struname("this"), "this"); |
|
|
|
|
|
|
29
|
|
|
$this->assertNotEquals($this->e->struname("1this"), "1This"); |
|
|
|
|
|
|
30
|
|
|
} |
|
31
|
|
|
|
|
32
|
|
|
public function test_stremail() { |
|
|
|
|
|
|
33
|
|
|
$this->assertEquals($this->e->stremail("[email protected]"), "[email protected]"); |
|
|
|
|
|
|
34
|
|
|
$this->assertEquals($this->e->stremail("[email protected]"), "[email protected]"); |
|
|
|
|
|
|
35
|
|
|
$this->assertEquals($this->e->stremail(" [email protected]"), "[email protected]"); |
|
|
|
|
|
|
36
|
|
|
$this->assertEquals($this->e->stremail("[email protected] "), "[email protected]"); |
|
|
|
|
|
|
37
|
|
|
$this->assertEquals($this->e->stremail("1this12345 @example.com"), "[email protected]"); |
|
|
|
|
|
|
38
|
|
|
$this->assertEquals($this->e->stremail("1this12345@ example.com"), "[email protected]"); |
|
|
|
|
|
|
39
|
|
|
|
|
40
|
|
|
// Sad Path |
|
41
|
|
|
$this->assertNotEquals($this->e->stremail(" [email protected]"), " [email protected]"); |
|
|
|
|
|
|
42
|
|
|
$this->assertNotEquals($this->e->stremail("[email protected] "), "[email protected] "); |
|
|
|
|
|
|
43
|
|
|
$this->assertNotEquals($this->e->stremail("1this12345 @example.com"), "1this12345 @example.com"); |
|
|
|
|
|
|
44
|
|
|
$this->assertNotEquals($this->e->stremail("1this12345@ example.com"), "1this12345@ example.com"); |
|
|
|
|
|
|
45
|
|
|
|
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
} |
|
49
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.