Completed
Push — master ( f323bf...0da584 )
by Byron
02:55
created

TranslateTest   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 6
Metric Value
wmc 1
lcom 0
cbo 6
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A testSuccessfulTranslate() 0 18 1
1
<?php
2
3
use GuzzleHttp\Client;
4
use GuzzleHttp\Subscriber\Mock;
5
use GuzzleHttp\Message\Response;
6
7
8
class TranslateTest extends \PHPUnit_Framework_TestCase
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    public function testSuccessfulTranslate()
11
    {
12
        $client = new Client();
13
14
        $content = GuzzleHttp\Stream\Stream::factory('{"access_token":"123"}');
15
16
        $mock = new Mock([
17
            new Response(200, [], $content),
18
            new Response(200, [], GuzzleHttp\Stream\Stream::factory('<string>Hallo</string>')),
19
        ]);
20
21
        $client->getEmitter()->attach($mock);
22
23
        $translator = new \badams\MicrosoftTranslator\MicrosoftTranslator($client);
24
        $translator->setClient('client_id', 'client_secret');
25
26
        $this->assertEquals('Hallo', $translator->translate('Hello', 'de', 'en'));
27
    }
28
29
}