-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
79 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit bootstrap="./tests/bootstrap.php" colors="true"> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="./tests/bootstrap.php" colors="true" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory>./</directory> | ||
</include> | ||
<exclude> | ||
<directory suffix="Interface.php">./</directory> | ||
<directory>./Resources</directory> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="microsoft-translator test suite"> | ||
<directory suffix="Test.php">./tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory>./</directory> | ||
<exclude> | ||
<directory>./Resources</directory> | ||
<directory>./tests</directory> | ||
<directory>./vendor</directory> | ||
</exclude> | ||
</whitelist> | ||
</filter> | ||
<!-- | ||
<php> | ||
<env name="MICROSOFT_AZURE_KEY" value="www"></env> | ||
<env name="MICROSOFT_OAUTH_CLIENT_ID" value="xxx"></env> | ||
<env name="MICROSOFT_OAUTH_CLIENT_SECRET" value="yyy"></env> | ||
<env name="MICROSOFT_TRANSLATOR_SAVE_AUDIO_TO" value="./" /> | ||
</php> | ||
--> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
tests/MatthiasNoback/MicrosoftTranslator/ApiCall/DictionaryLookupTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
namespace MatthiasNoback\Tests\MicrosoftTranslator\ApiCall; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use MatthiasNoback\MicrosoftTranslator\ApiCall; | ||
|
||
class DictionaryLookupTest extends TestCase | ||
{ | ||
public function testValidatesLengthOfText() | ||
{ | ||
$text = str_repeat('t', 10001); | ||
|
||
$this->expectException('\InvalidArgumentException'); | ||
|
||
new ApiCall\DictionaryLookup($text, 'nl'); | ||
} | ||
|
||
public function testGetRequestToDictionaryLookupCallContent() | ||
{ | ||
$apiCall = new ApiCall\DictionaryLookup('text', 'nl'); | ||
|
||
$this->assertSame('dictionary/lookup', $apiCall->getApiMethodName()); | ||
$this->assertSame('POST', $apiCall->getHttpMethod()); | ||
$this->assertSame([['Text' => 'text']], $apiCall->getRequestContent()); | ||
} | ||
|
||
public function testQueryParameters() | ||
{ | ||
$text = 'text'; | ||
$from = 'from'; | ||
$to = 'to'; | ||
|
||
$apiCall = new ApiCall\DictionaryLookup($text, $to, $from); | ||
$this->assertEquals(array( | ||
'from' => $from, | ||
'to' => $to | ||
), $apiCall->getQueryParameters()); | ||
} | ||
|
||
public function testParseResponse() | ||
{ | ||
$apiCall = new ApiCall\DictionaryLookup('peter', 'eu'); | ||
|
||
$response = json_encode([ | ||
['translations' => [ | ||
['text' => 'Dit is een test'], | ||
]] | ||
]); | ||
|
||
$this->assertSame([['text' => 'Dit is een test']], $apiCall->parseResponse($response)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters