refactor: replace custom CRM with Monica fork
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
Some checks failed
Build & Push Monica Image to Gitea Registry / build-and-push (push) Failing after 9s
This commit is contained in:
65
tests/Unit/Traits/SearchableTest.php
Normal file
65
tests/Unit/Traits/SearchableTest.php
Normal file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Unit\Traits;
|
||||
|
||||
use Tests\TestCase;
|
||||
use App\Models\Contact\Contact;
|
||||
use Illuminate\Foundation\Testing\DatabaseTransactions;
|
||||
|
||||
class SearchableTest extends TestCase
|
||||
{
|
||||
use DatabaseTransactions;
|
||||
|
||||
/** @test */
|
||||
public function testSearchContactsReturnsCollection()
|
||||
{
|
||||
$contact = factory(Contact::class)->make();
|
||||
$searchResults = $contact->search($contact->first_name, $contact->account_id, 'created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$this->assertInstanceOf('Illuminate\Pagination\LengthAwarePaginator', $searchResults);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function testSearchContactsThroughFirstNameAndResultContainsContact()
|
||||
{
|
||||
$contact = factory(Contact::class)->create(['first_name' => 'FirstName']);
|
||||
$searchResults = $contact->search($contact->first_name, $contact->account_id, 'created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$this->assertTrue($searchResults->contains($contact));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function testSearchContactsThroughMiddleNameAndResultContainsContact()
|
||||
{
|
||||
$contact = factory(Contact::class)->create(['middle_name' => 'MiddleName']);
|
||||
$searchResults = $contact->search($contact->middle_name, $contact->account_id, 'created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$this->assertTrue($searchResults->contains($contact));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
public function testSearchContactsThroughLastNameAndResultContainsContact()
|
||||
{
|
||||
$contact = factory(Contact::class)->create(['last_name' => 'LastName']);
|
||||
$searchResults = $contact->search($contact->last_name, $contact->account_id, 'created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$this->assertTrue($searchResults->contains($contact));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @psalm-suppress UndefinedFunction
|
||||
*/
|
||||
public function testFailingSearchContacts()
|
||||
{
|
||||
$contact = factory(Contact::class)->create(['first_name' => 'TestShouldFail']);
|
||||
$searchResults = $contact->search('TestWillSucceed', $contact->account_id, 'created_at', 'desc')
|
||||
->paginate(10);
|
||||
|
||||
$this->assertFalse($searchResults->contains($contact));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user