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

TranslateTest::testSuccessfulTranslate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 18
Code Lines 10

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 18
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
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
}