public function testSuccessfulTranslate() { $client = new Client(); $content = Stream::factory('{"access_token":"123"}'); $mock = new Mock([new Response(200, [], $content), new Response(200, [], Stream::factory($this->xmlResponse))]); $client->getEmitter()->attach($mock); $translator = new \badams\MicrosoftTranslator\MicrosoftTranslator($client); $translator->setClient('client_id', 'client_secret'); $results = $translator->getTranslationsArray(['Hello', 'World'], 'de', 'en'); $this->assertTrue(is_array($results)); $this->assertEquals(2, count($results)); $this->assertInstanceOf('\\badams\\MicrosoftTranslator\\Responses\\GetTranslationsResponse', $results[0]); $this->assertInstanceOf('\\badams\\MicrosoftTranslator\\Language', $results[0]->getFrom()); $this->assertEquals('en', (string) $results[0]->getFrom()); $translations = $results[0]->getTranslations(); $this->assertEquals(2, count($translations)); $this->assertInstanceOf('\\badams\\MicrosoftTranslator\\Responses\\TranslationMatch', $translations[0]); $this->assertEquals('Hallo', $translations[0]->getTranslatedText()); $this->assertEquals(5, $translations[0]->getRating()); $this->assertEquals(100, $translations[0]->getMatchDegree()); $this->assertEquals(null, $translations[0]->getError()); $this->assertEquals(0, $translations[0]->getCount()); $this->assertEquals('', $translations[0]->getMatchedOriginalText()); $this->assertEquals('Hello', $translations[1]->getTranslatedText()); $this->assertEquals(4, $translations[1]->getRating()); $this->assertEquals(70, $translations[1]->getMatchDegree()); $this->assertEquals(null, $translations[1]->getError()); $this->assertEquals(1, $translations[1]->getCount()); $this->assertEquals('Hello', $translations[1]->getMatchedOriginalText()); }