TextCatLanguageDetectorTest::testCanConstruct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 0
1
<?php
2
3
namespace Onoi\Tesa\Tests\LanguageDetector;
4
5
use Onoi\Tesa\LanguageDetector\TextCatLanguageDetector;
6
7
/**
8
 * @covers \Onoi\Tesa\LanguageDetector\TextCatLanguageDetector
9
 * @group onoi-tesa
10
 *
11
 * @license GNU GPL v2+
12
 * @since 0.1
13
 *
14
 * @author mwjames
15
 */
16
class TextCatLanguageDetectorTest extends \PHPUnit_Framework_TestCase {
17
18
	public function testCanConstruct() {
19
20
		$this->assertInstanceOf(
21
			'\Onoi\Tesa\LanguageDetector\TextCatLanguageDetector',
22
			new TextCatLanguageDetector()
23
		);
24
	}
25
26
	public function testDetectOnMock() {
27
28
		$languageCandidates = array( 'en', 'de', 'fr', 'es', 'ja', 'zh' );
29
30
		$textCat = $this->getMockBuilder( '\TextCat' )
31
			->disableOriginalConstructor()
32
			->getMock();
33
34
		$textCat->expects( $this->once() )
35
			->method( 'classify' )
36
			->with(
37
				$this->equalTo( 'Foo' ),
38
				$this->equalTo( $languageCandidates ) )
39
			->will( $this->returnValue( array() ) );
40
41
		$instance = new TextCatLanguageDetector( $textCat );
42
		$instance->setLanguageCandidates(
43
			$languageCandidates
44
		);
45
46
		$instance->detect( 'Foo' );
47
	}
48
49
}
50