Skip to content

Commit

Permalink
Added more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskonnertz committed Sep 13, 2017
1 parent feadf74 commit b39e10a
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions tests/MainClassTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,19 @@ public function testPing()
$deepLy->ping();
}

public function testSplitText()
{
$deepLy = $this->getInstance();

$sentences = $deepLy->splitText('Hello world! What a wonderful world.', 'EN');

$numberOfSentences = sizeof($sentences);
$this->assertEquals(2, $numberOfSentences);

$expectedSentences = ['Hello world!', 'What a wonderful world.'];
$this->assertEquals($expectedSentences, $sentences);
}

public function testTranslation()
{
$deepLy = $this->getInstance();
Expand All @@ -83,6 +96,40 @@ public function testTranslation()
$this->assertNotNull($translationAlternatives);
}

public function testProposeTranslations()
{
$deepLy = $this->getInstance();

$proposals = $deepLy->proposeTranslations('The old man an the sea', 'DE', 'EN');

$numberOfProposals = sizeof($proposals);
$this->assertEquals(4, $numberOfProposals);

// We assume that the result will look like this.
// If the result will change for some reason,
// of course the test will fail
$expectedProposals = [
'Der alte Mann am Meer',
'Der alte Mann und das Meer',
'Der Alte und das Meer',
'Der Alte am Meer',
];
$this->assertEquals($expectedProposals, $proposals);
}

public function testTranslateSentences()
{
$deepLy = $this->getInstance();

$sentences = $deepLy->translateSentences('Hello world! What a wonderful world.', 'DE', 'EN');

$numberOfSentences = sizeof($sentences);
$this->assertEquals(2, $numberOfSentences);

$expectedSentences = ['Hallo Welt!', 'Was für eine wunderbare Welt.'];
$this->assertEquals($expectedSentences, $sentences);
}

public function testGetTranslationBag()
{
$deepLy = $this->getInstance();
Expand Down

0 comments on commit b39e10a

Please sign in to comment.