enwikipedia-acc /
waca
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | View Code Duplication | class StringFunctionsTest extends PHPUnit_Framework_TestCase |
|
|
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. Loading history...
|
|||
| 4 | { |
||
| 5 | private $e; |
||
| 6 | |||
| 7 | public function setUp() |
||
| 8 | { |
||
| 9 | |||
| 10 | $this->e = new StringFunctions(); |
||
| 11 | } |
||
| 12 | |||
| 13 | public function tearDown() { |
||
| 14 | $this->e = NULL; |
||
| 15 | } |
||
| 16 | |||
| 17 | public function test_formatAsUsername() { |
||
|
0 ignored issues
–
show
This method is not in camel caps format.
This check looks for method names that are not written in camelCase. In camelCase names are written without any punctuation, the start of each new
word being marked by a capital letter. Thus the name
database connection seeker becomes Loading history...
|
|||
| 18 | // Happy path |
||
| 19 | $this->assertEquals($this->e->formatAsUsername("this"), "This"); |
||
| 20 | $this->assertEquals($this->e->formatAsUsername("1this"), "1this"); |
||
| 21 | $this->assertEquals($this->e->formatAsUsername("This"), "This"); |
||
| 22 | $this->assertEquals($this->e->formatAsUsername("This "), "This"); |
||
| 23 | $this->assertEquals($this->e->formatAsUsername("This_"), "This"); |
||
| 24 | |||
| 25 | // Sad Path |
||
| 26 | $this->assertNotEquals($this->e->formatAsUsername("This "), "This "); |
||
| 27 | $this->assertNotEquals($this->e->formatAsUsername("This_"), "This_"); |
||
| 28 | $this->assertNotEquals($this->e->formatAsUsername("this"), "this"); |
||
| 29 | $this->assertNotEquals($this->e->formatAsUsername("1this"), "1This"); |
||
| 30 | } |
||
| 31 | |||
| 32 | public function test_formatAsEmail() { |
||
|
0 ignored issues
–
show
This method is not in camel caps format.
This check looks for method names that are not written in camelCase. In camelCase names are written without any punctuation, the start of each new
word being marked by a capital letter. Thus the name
database connection seeker becomes Loading history...
|
|||
| 33 | $this->assertEquals($this->e->formatAsEmail("[email protected]"), "[email protected]"); |
||
| 34 | $this->assertEquals($this->e->formatAsEmail("[email protected]"), "[email protected]"); |
||
| 35 | $this->assertEquals($this->e->formatAsEmail(" [email protected]"), "[email protected]"); |
||
| 36 | $this->assertEquals($this->e->formatAsEmail("[email protected] "), "[email protected]"); |
||
| 37 | $this->assertEquals($this->e->formatAsEmail("1this12345 @example.com"), "[email protected]"); |
||
| 38 | $this->assertEquals($this->e->formatAsEmail("1this12345@ example.com"), "[email protected]"); |
||
| 39 | |||
| 40 | // Sad Path |
||
| 41 | $this->assertNotEquals($this->e->formatAsEmail(" [email protected]"), " [email protected]"); |
||
| 42 | $this->assertNotEquals($this->e->formatAsEmail("[email protected] "), "[email protected] "); |
||
| 43 | $this->assertNotEquals($this->e->formatAsEmail("1this12345 @example.com"), "1this12345 @example.com"); |
||
| 44 | $this->assertNotEquals($this->e->formatAsEmail("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.