1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Stichoza\GoogleTranslate\Tests; |
4
|
|
|
|
5
|
|
|
use Stichoza\GoogleTranslate\TranslateClient; |
6
|
|
|
|
7
|
|
|
class LanguageDetectionTest extends \PHPUnit_Framework_TestCase |
|
|
|
|
8
|
|
|
{ |
9
|
|
|
public function setUp() |
10
|
|
|
{ |
11
|
|
|
$this->tr = new TranslateClient(); |
|
|
|
|
12
|
|
|
} |
13
|
|
|
|
14
|
|
|
public function testSingleWord() |
15
|
|
|
{ |
16
|
|
|
$this->tr->translate('გამარჯობა'); |
17
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'ka'); |
18
|
|
|
|
19
|
|
|
$this->tr->translate('Cześć'); |
20
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'pl'); |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
public function testSingleSentence() |
24
|
|
|
{ |
25
|
|
|
$this->tr->translate('იყო არაბეთს როსტევან'); |
26
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'ka'); |
27
|
|
|
|
28
|
|
|
$this->tr->translate('Путин хуйло'); |
29
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'ru'); |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
public function testMultipleSentence() |
33
|
|
|
{ |
34
|
|
|
$this->tr->translate('ჩემი ხატია სამშობლო. სახატე - მთელი ქვეყანა. განათებული მთა-ბარი.'); |
35
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'ka'); |
36
|
|
|
|
37
|
|
|
$this->tr->translate('Ще не вмерла Україна, И слава, и воля! Ще намъ, браття-молодці, Усміхнеться доля!'); |
38
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'uk'); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function testStaticAndNonStaticDetection() |
42
|
|
|
{ |
43
|
|
|
$this->tr->translate('გამარჯობა'); |
44
|
|
|
|
45
|
|
|
TranslateClient::translate(null, 'en', 'Cześć'); |
|
|
|
|
46
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'pl'); |
47
|
|
|
$this->assertEquals(TranslateClient::getLastDetectedSource(), 'pl'); |
|
|
|
|
48
|
|
|
|
49
|
|
|
$this->tr->translate('გამარჯობა'); |
50
|
|
|
$this->assertEquals($this->tr->getLastDetectedSource(), 'ka'); |
51
|
|
|
$this->assertEquals(TranslateClient::getLastDetectedSource(), 'ka'); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|
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:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths