SanitizerFactoryTest   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 179
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 20
lcom 1
cbo 1
dl 0
loc 179
rs 10
c 0
b 0
f 0

20 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testCanConstructSanitizer() 0 7 1
A testCanConstructStopwordAnalyzerByNullLanguage() 0 7 1
A testCanConstructStopwordAnalyzerByEnLanguage() 0 7 1
A testCanConstructCdbStopwordAnalyzer() 0 7 1
A testCanConstructArrayStopwordAnalyzer() 0 7 1
A testCanConstructNullStopwordAnalyzer() 0 7 1
A testCanConstructSynonymizerByLanguage() 0 7 1
A testCanConstructNullSynonymizer() 0 7 1
A testCanConstructNullLanguageDetector() 0 7 1
A testCanConstructTextCatLanguageDetector() 0 7 1
A testCanConstructPreferredTokenizerByLanguage() 0 12 1
A testCanConstructnewCJKMatchableTokenizer() 0 12 1
A testCanConstructIcuWordBoundaryTokenizer() 0 7 1
A testCanConstructGenericRegExTokenizer() 0 7 1
A testCanConstructPunctuationRegExTokenizer() 0 7 1
A testCanConstructJaCompoundGroupTokenizer() 0 7 1
A testCanConstructJaTinySegmenterTokenizer() 0 7 1
A testCanConstructCJKSimpleCharacterRegExTokenizer() 0 7 1
A testCanConstructNGramTokenizer() 0 7 1
1
<?php
2
3
namespace Onoi\Tesa\Tests;
4
5
use Onoi\Tesa\SanitizerFactory;
6
7
/**
8
 * @covers \Onoi\Tesa\SanitizerFactory
9
 * @group onoi-tesa
10
 *
11
 * @license GNU GPL v2+
12
 * @since 0.1
13
 *
14
 * @author mwjames
15
 */
16
class SanitizerFactoryTest extends \PHPUnit_Framework_TestCase {
17
18
	private $sanitizerFactory;
19
20
	protected function setUp() {
21
		$this->sanitizerFactory = new SanitizerFactory();
22
	}
23
24
	public function testCanConstructSanitizer() {
25
26
		$this->assertInstanceOf(
27
			'\Onoi\Tesa\Sanitizer',
28
			$this->sanitizerFactory->newSanitizer()
29
		);
30
	}
31
32
	/* StopwordAnalyzer */
33
34
	public function testCanConstructStopwordAnalyzerByNullLanguage() {
35
36
		$this->assertInstanceOf(
37
			'\Onoi\Tesa\StopwordAnalyzer\StopwordAnalyzer',
38
			$this->sanitizerFactory->newStopwordAnalyzerByLanguage( null )
39
		);
40
	}
41
42
	public function testCanConstructStopwordAnalyzerByEnLanguage() {
43
44
		$this->assertInstanceOf(
45
			'\Onoi\Tesa\StopwordAnalyzer\CdbStopwordAnalyzer',
46
			$this->sanitizerFactory->newStopwordAnalyzerByLanguage( 'EN' )
47
		);
48
	}
49
50
	public function testCanConstructCdbStopwordAnalyzer() {
51
52
		$this->assertInstanceOf(
53
			'\Onoi\Tesa\StopwordAnalyzer\CdbStopwordAnalyzer',
54
			$this->sanitizerFactory->newCdbStopwordAnalyzer()
55
		);
56
	}
57
58
	public function testCanConstructArrayStopwordAnalyzer() {
59
60
		$this->assertInstanceOf(
61
			'\Onoi\Tesa\StopwordAnalyzer\ArrayStopwordAnalyzer',
62
			$this->sanitizerFactory->newArrayStopwordAnalyzer()
63
		);
64
	}
65
66
	public function testCanConstructNullStopwordAnalyzer() {
67
68
		$this->assertInstanceOf(
69
			'\Onoi\Tesa\StopwordAnalyzer\NullStopwordAnalyzer',
70
			$this->sanitizerFactory->newNullStopwordAnalyzer()
71
		);
72
	}
73
74
	/* Synonymizer */
75
76
	public function testCanConstructSynonymizerByLanguage() {
77
78
		$this->assertInstanceOf(
79
			'\Onoi\Tesa\Synonymizer\Synonymizer',
80
			$this->sanitizerFactory->newSynonymizerByLanguage()
81
		);
82
	}
83
84
	public function testCanConstructNullSynonymizer() {
85
86
		$this->assertInstanceOf(
87
			'\Onoi\Tesa\Synonymizer\NullSynonymizer',
88
			$this->sanitizerFactory->newNullSynonymizer()
89
		);
90
	}
91
92
	/* LanguageDetector */
93
94
	public function testCanConstructNullLanguageDetector() {
95
96
		$this->assertInstanceOf(
97
			'\Onoi\Tesa\LanguageDetector\NullLanguageDetector',
98
			$this->sanitizerFactory->newNullLanguageDetector()
99
		);
100
	}
101
102
	public function testCanConstructTextCatLanguageDetector() {
103
104
		$this->assertInstanceOf(
105
			'\Onoi\Tesa\LanguageDetector\TextCatLanguageDetector',
106
			$this->sanitizerFactory->newTextCatLanguageDetector()
107
		);
108
	}
109
110
	/* Tokenizer */
111
112
	public function testCanConstructPreferredTokenizerByLanguage() {
113
114
		$this->assertInstanceOf(
115
			'\Onoi\Tesa\Tokenizer\Tokenizer',
116
			$this->sanitizerFactory->newPreferredTokenizerByLanguage( 'テスト' )
117
		);
118
119
		$this->assertInstanceOf(
120
			'\Onoi\Tesa\Tokenizer\Tokenizer',
121
			$this->sanitizerFactory->newPreferredTokenizerByLanguage( '在延安更名为新' )
122
		);
123
	}
124
125
	public function testCanConstructnewCJKMatchableTokenizer() {
126
127
		$this->assertInstanceOf(
128
			'\Onoi\Tesa\Tokenizer\Tokenizer',
129
			$this->sanitizerFactory->newCJKMatchableTokenizer( 'テスト' )
130
		);
131
132
		$this->assertInstanceOf(
133
			'\Onoi\Tesa\Tokenizer\Tokenizer',
134
			$this->sanitizerFactory->newCJKMatchableTokenizer( '在延安更名为新' )
135
		);
136
	}
137
138
	public function testCanConstructIcuWordBoundaryTokenizer() {
139
140
		$this->assertInstanceOf(
141
			'\Onoi\Tesa\Tokenizer\IcuWordBoundaryTokenizer',
142
			$this->sanitizerFactory->newIcuWordBoundaryTokenizer()
143
		);
144
	}
145
146
	public function testCanConstructGenericRegExTokenizer() {
147
148
		$this->assertInstanceOf(
149
			'\Onoi\Tesa\Tokenizer\GenericRegExTokenizer',
150
			$this->sanitizerFactory->newGenericRegExTokenizer()
151
		);
152
	}
153
154
	public function testCanConstructPunctuationRegExTokenizer() {
155
156
		$this->assertInstanceOf(
157
			'\Onoi\Tesa\Tokenizer\PunctuationRegExTokenizer',
158
			$this->sanitizerFactory->newPunctuationRegExTokenizer()
159
		);
160
	}
161
162
	public function testCanConstructJaCompoundGroupTokenizer() {
163
164
		$this->assertInstanceOf(
165
			'\Onoi\Tesa\Tokenizer\JaCompoundGroupTokenizer',
166
			$this->sanitizerFactory->newJaCompoundGroupTokenizer()
167
		);
168
	}
169
170
	public function testCanConstructJaTinySegmenterTokenizer() {
171
172
		$this->assertInstanceOf(
173
			'\Onoi\Tesa\Tokenizer\JaTinySegmenterTokenizer',
174
			$this->sanitizerFactory->newJaTinySegmenterTokenizer()
175
		);
176
	}
177
178
	public function testCanConstructCJKSimpleCharacterRegExTokenizer() {
179
180
		$this->assertInstanceOf(
181
			'\Onoi\Tesa\Tokenizer\CJKSimpleCharacterRegExTokenizer',
182
			$this->sanitizerFactory->newCJKSimpleCharacterRegExTokenizer()
183
		);
184
	}
185
186
	public function testCanConstructNGramTokenizer() {
187
188
		$this->assertInstanceOf(
189
			'\Onoi\Tesa\Tokenizer\NGramTokenizer',
190
			$this->sanitizerFactory->newNGramTokenizer()
191
		);
192
	}
193
194
}
195