From 7429f454ebd9f2f44c16c7cbff8c08bb9bbaf512 Mon Sep 17 00:00:00 2001 From: Yuri Kuznetsov Date: Thu, 13 May 2021 16:50:45 +0300 Subject: [PATCH] fix test --- .../Espo/Email/SearchByEmailAddressTest.php | 46 ++++++++++++------- 1 file changed, 30 insertions(+), 16 deletions(-) diff --git a/tests/integration/Espo/Email/SearchByEmailAddressTest.php b/tests/integration/Espo/Email/SearchByEmailAddressTest.php index b22820aa49..c4b685502e 100644 --- a/tests/integration/Espo/Email/SearchByEmailAddressTest.php +++ b/tests/integration/Espo/Email/SearchByEmailAddressTest.php @@ -29,29 +29,35 @@ namespace tests\integration\Espo\Email; +use Espo\Core\Select\SearchParams; + class SearchByEmailAddressTest extends \tests\integration\Core\BaseTestCase { - public function testSearchByEmailAddress() { $entityManager = $this->getContainer()->get('entityManager'); $email = $entityManager->getEntity('Email'); + $email->set('from', 'test@test.com'); $email->set('status', 'Archived'); + $entityManager->saveEntity($email); $emailService = $this->getApplication()->getContainer()->get('serviceFactory')->create('Email'); - $result = $emailService->find(array( - 'where' => array( - array( - 'type' => 'equals', - 'attribute' => 'emailAddress', - 'value' => 'test@test.com' - ) - ) - )); + $result = $emailService->find( + SearchParams::fromRaw([ + 'where' => [ + [ + 'type' => 'equals', + 'attribute' => 'emailAddress', + 'value' => 'test@test.com' + ] + ] + ]) + ); + $this->assertEquals(1, count($result->getCollection())); } @@ -60,22 +66,30 @@ class SearchByEmailAddressTest extends \tests\integration\Core\BaseTestCase $entityManager = $this->getContainer()->get('entityManager'); $email = $entityManager->getEntity('Email'); + $email->set('from', 'test@test.com'); $email->set('status', 'Archived'); $email->set('name', 'Improvements to our Privacy Policy'); $email->set('body', 'name abc test'); + $entityManager->saveEntity($email); $emailService = $this->getApplication()->getContainer()->get('serviceFactory')->create('Email'); - $result = $emailService->find([ - 'textFilter' => 'name abc' - ]); + $result = $emailService->find( + SearchParams::fromRaw([ + 'textFilter' => 'name abc' + ]) + ); + $this->assertEquals(1, count($result->getCollection())); - $result = $emailService->find([ - 'textFilter' => 'Improvements to our Privacy Policy' - ]); + $result = $emailService->find( + SearchParams::fromRaw([ + 'textFilter' => 'Improvements to our Privacy Policy' + ]) + ); + $this->assertEquals(1, count($result->getCollection())); } }