Passed
Push — master ( fda1e3...cbd2ad )
by Michael
01:55
created

StringFunctionsTest::testFormatAsUsername()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 9
nc 1
nop 0
dl 0
loc 13
rs 9.9666
c 0
b 0
f 0
1
<?php
2
3
use PHPUnit\Framework\TestCase;
0 ignored issues
show
Bug introduced by
The type PHPUnit\Framework\TestCase was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
4
5
class StringFunctionsTest extends TestCase
6
{
7
	/**
8
	 * @var StringFunctions
9
	 */
10
	private $e;
11
12
	public function setUp(): void
13
	{
14
		$this->e = new StringFunctions();
15
	}
16
17
	public function tearDown(): void
18
	{
19
		$this->e = null;
20
	}
21
22
	public function testFormatAsUsername()	{
23
		// Happy path
24
		$this->assertEquals($this->e->formatAsUsername("this"), "This");
25
		$this->assertEquals($this->e->formatAsUsername("1this"), "1this");
26
		$this->assertEquals($this->e->formatAsUsername("This"), "This");
27
		$this->assertEquals($this->e->formatAsUsername("This "), "This");
28
		$this->assertEquals($this->e->formatAsUsername("This_"), "This");
29
30
		// Sad Path
31
		$this->assertNotEquals($this->e->formatAsUsername("This "), "This ");
32
		$this->assertNotEquals($this->e->formatAsUsername("This_"), "This_");
33
		$this->assertNotEquals($this->e->formatAsUsername("this"), "this");
34
		$this->assertNotEquals($this->e->formatAsUsername("1this"), "1This");
35
	}
36
37
	public function testFormatAsEmail()
38
	{
39
		$this->assertEquals($this->e->formatAsEmail("[email protected]"), "[email protected]");
40
		$this->assertEquals($this->e->formatAsEmail("[email protected]"), "[email protected]");
41
		$this->assertEquals($this->e->formatAsEmail(" [email protected]"), "[email protected]");
42
		$this->assertEquals($this->e->formatAsEmail("[email protected] "), "[email protected]");
43
		$this->assertEquals($this->e->formatAsEmail("1this12345 @example.com"), "[email protected]");
44
		$this->assertEquals($this->e->formatAsEmail("1this12345@ example.com"), "[email protected]");
45
46
		// Sad Path
47
		$this->assertNotEquals($this->e->formatAsEmail(" [email protected]"), " [email protected]");
48
		$this->assertNotEquals($this->e->formatAsEmail("[email protected] "), "[email protected] ");
49
		$this->assertNotEquals($this->e->formatAsEmail("1this12345 @example.com"), "1this12345 @example.com");
50
		$this->assertNotEquals($this->e->formatAsEmail("1this12345@ example.com"), "1this12345@ example.com");
51
	}
52
}
53