Completed
Push — master ( 2ad0de...2fd600 )
by Levan
03:06
created

TranslationTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Stichoza\GoogleTranslate\Tests;
4
5
use PHPUnit\Framework\TestCase;
6
use Stichoza\GoogleTranslate\GoogleTranslate;
7
8
class TranslationTest extends TestCase
9
{
10
    public $tr;
11
12
    public function setUp()
13
    {
14
        $this->tr = new GoogleTranslate();
15
    }
16
17 View Code Duplication
    public function testTranslationEquality()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
18
    {
19
        try {
20
            $resultOne = GoogleTranslate::trans('Hello', 'ka', 'en');
21
        } catch (\ErrorException $e) {
0 ignored issues
show
Bug introduced by
The class ErrorException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
22
            $resultOne = null;
23
        }
24
        $resultTwo = $this->tr->setSource('en')->setTarget('ka')->translate('Hello');
25
26
        $this->assertEquals($resultOne, $resultTwo, 'გამარჯობა');
27
    }
28
29 View Code Duplication
    public function testUTF16Translation()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30
    {
31
        try {
32
            $resultOne = GoogleTranslate::trans('yes 👍🏽', 'de', 'en');
33
        } catch (\ErrorException $e) {
0 ignored issues
show
Bug introduced by
The class ErrorException does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
34
            $resultOne = null;
35
        }
36
        $resultTwo = $this->tr->setSource('en')->setTarget('de')->translate('yes 👍🏽');
37
38
        $this->assertEquals($resultOne, $resultTwo, 'ja 👍🏽');
39
    }
40
41
    public function testRawResponse()
42
    {
43
        $rawResult = $this->tr->getResponse('cat');
44
45
        $this->assertTrue(is_array($rawResult), 'Method getResponse() should return an array.');
46
    }
47
}
48