LinkFinderTest::testCompileText()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 15
rs 9.7666
c 0
b 0
f 0
1
<?php
2
3
namespace MailSoTests;
4
5
class LinkFinderTest extends \PHPUnit_Framework_TestCase
6
{
7
	/**
8
	 * @var \MailSo\Base\LinkFinder
9
	 */
10
	protected $object;
11
12
	protected function setUp()
13
	{
14
		$this->object = \MailSo\Base\LinkFinder::NewInstance();
15
	}
16
17
	protected function tearDown()
18
	{
19
		$this->object = null;
20
	}
21
22
	public function testNewInstance()
23
	{
24
		$this->assertTrue($this->object instanceof \MailSo\Base\LinkFinder);
0 ignored issues
show
Bug introduced by
The class MailSo\Base\LinkFinder does not exist. Did you forget a USE statement, or did you not list all dependencies?

This error could be the result of:

1. Missing dependencies

PHP Analyzer uses your composer.json file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects the composer.json to be in the root folder of your repository.

Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the require or require-dev section?

2. Missing use statement

PHP does not complain about undefined classes in ìnstanceof checks. For example, the following PHP code will work perfectly fine:

if ($x instanceof DoesNotExist) {
    // Do something.
}

If you have not tested against this specific condition, such errors might go unnoticed.

Loading history...
25
	}
26
27
	public function testClear()
28
	{
29
		$this->object->Text('111');
30
		$this->assertEquals('111', $this->object->CompileText());
31
		$this->object->Clear();
32
		$this->assertEquals('', $this->object->CompileText());
33
	}
34
35
	public function testText()
36
	{
37
		$this->object->Text('222');
38
		$this->assertEquals('222', $this->object->CompileText());
39
	}
40
41
	public function testLinkWrapper()
42
	{
43
		$this->object
44
			->Text('333 http://domain.com 333')
45
			->LinkWrapper(function ($sLink) {
46
				return '!'.$sLink.'!';
47
			})
48
		;
49
50
		$this->assertEquals('333 !http://domain.com! 333', $this->object->CompileText());
51
	}
52
53
	public function testMailWrapper()
54
	{
55
		$this->object
56
			->Text('444 [email protected] 444')
57
			->MailWrapper(function ($sMail) {
58
				return '!'.$sMail.'!';
59
			})
60
		;
61
62
		$this->assertEquals('444 [email protected]! 444', $this->object->CompileText());
63
	}
64
65
	public function testUseDefaultWrappers()
66
	{
67
		$this->object
68
			->Text('555 http://domain.com [email protected] 555')
69
			->UseDefaultWrappers()
70
		;
71
72
		$this->assertEquals('555 <a href="http://domain.com">http://domain.com</a> <a href="mailto:[email protected]">[email protected]</a> 555',
73
			$this->object->CompileText());
74
75
		$this->object->UseDefaultWrappers(true);
76
77
		$this->assertEquals('555 <a target="_blank" href="http://domain.com">http://domain.com</a> <a target="_blank" href="mailto:[email protected]">[email protected]</a> 555',
78
			$this->object->CompileText());
79
	}
80
81
	public function testCompileText()
82
	{
83
		$this->object
84
			->Text('777 http://domain.com domain.com [email protected] <> 777')
85
			->LinkWrapper(function ($sLink) {
86
				return '~'.$sLink.'~';
87
			})
88
			->MailWrapper(function ($sMail) {
89
				return '~'.$sMail.'~';
90
			})
91
		;
92
93
		$this->assertEquals('777 ~http://domain.com~ domain.com [email protected]~ &lt;&gt; 777', $this->object->CompileText(true));
94
		$this->assertEquals('777 ~http://domain.com~ domain.com [email protected]~ <> 777', $this->object->CompileText(false));
95
	}
96
}
97