Add a test for Word and LexicalEntry relationships

This commit is contained in:
Leonard Smith 2020-10-07 11:06:15 -05:00
parent b329bed0d4
commit f24df2563a
2 changed files with 43 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<?php
namespace Tests\Unit;
use App\LexicalEntry;
use App\Word;
use Tests\TestCase;
class LexicalEntryTest extends TestCase
{
public function testWordLexicalEntryRelationship()
{
$lexicalEntry = LexicalEntry::where('id', 'G2041')->with('words')->first();
$this->assertNotEmpty($lexicalEntry, 'Must be able to find a valid LexicalEntry');
$lWord = $lexicalEntry->words[0];
$word = Word::find($lWord->id);
$this->assertNotEmpty($word, 'Must be able to find a matching Word');
$this->assertEquals($lexicalEntry->words[0], $word);
}}

21
tests/Unit/WordTest.php Normal file
View File

@ -0,0 +1,21 @@
<?php
namespace Tests\Unit;
use App\LexicalEntry;
use App\Word;
use Tests\TestCase;
class WordTest extends TestCase
{
public function testWordLexicalEntryRelationship()
{
$word = Word::with('lexicalEntry')->first();
$this->assertNotEmpty($word, 'Must be able to find a valid word');
$lexicalEntry = LexicalEntry::find($word->strongs_number);
$this->assertNotEmpty($lexicalEntry, 'Must be able to find a matching LexicalEntry');
$this->assertEquals($word->lexicalEntry, $lexicalEntry);
}
}