This repository has been archived on 2019-03-01. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
paper-pi/tests/Unit/VocabularyTest.php

72 lines
2.5 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
namespace Tests\Unit;
use App\Paper\Vocabulary;
use Tests\TestCase;
class VocabularyTest extends TestCase
{
public function testGetExistingWordData()
{
$voc = new Vocabulary();
$data = $voc->getWordData('random');
$this->assertNotEmpty($data);
$element = $data->find('.wordPage[data-word="random"]');
$this->assertCount(1, $element);
}
public function testGetNonExistingWordData()
{
$nonExistingWord = time();
$voc = new Vocabulary();
$data = $voc->getWordData($nonExistingWord);
$this->assertNotEmpty($data);
$element = $data->find('.wordPage[data-word="random"]');
$this->assertCount(0, $element);
$elementNotFound = $data->find('.noresults[data-search="' . $nonExistingWord . '"]');
$this->assertCount(1, $elementNotFound);
}
public function testGetExistingWord()
{
$dummyWord = 'dummy';
$vot = new Vocabulary();
$word = $vot->getWord($dummyWord);
$this->assertEquals('en', $word->lang);
$this->assertEquals('dummy', $word->word);
$this->assertEquals('dump', $word->next);
$this->assertEquals('dumbstruck', $word->prev);
$this->assertEquals('Have you ever seen an entertainer make a doll look like its talking? The entertainer is using a dummy — a doll made to look like a person.', $word->short);
$this->assertEquals("A dummy is a type of doll that looks like a person. Entertainers called ventriloquists can make dummies appear to talk. The automobile industry uses dummies in cars to study how safe cars are during a crash. A dummy can also be anything that looks real but doesnt work: a fake. Actors in a play might use certain props that are dummies, such as a dummy laptop. Dummy is also an insult used to mean “an ignorant person.”", $word->long);
}
public function testGetRandomWord()
{
$vot = new Vocabulary();
$word = $vot->getRandomWord();
$this->assertNotNull($word);
}
public function testGetRandomWordData()
{
$vot = new Vocabulary();
$word = $vot->getRandomWord();
$this->assertNotNull($word);
$wordData = $vot->getWord($word);
$this->assertEquals('en', $wordData->lang);
$this->assertNotEmpty($wordData->word);
$this->assertNotEmpty($wordData->next);
$this->assertNotEmpty($wordData->prev);
$this->assertNotEmpty($wordData->short);
$this->assertNotEmpty($wordData->long);
}
}