forked from BitBagCommerce/SyliusBlacklistPlugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
83 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
<?php | ||
|
||
/* | ||
* This file has been created by developers from BitBag. | ||
* Feel free to contact us once you face any issues or want to start | ||
* You can find more information about us on https://bitbag.io and write us | ||
* an email on [email protected]. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Tests\BitBag\SyliusBlacklistPlugin\PHPUnit\Integration; | ||
|
||
use Tests\BitBag\SyliusBlacklistPlugin\Repository\CustomerRepository; | ||
|
||
class CustomerRepositoryTest extends IntegrationTestCase | ||
{ | ||
private CustomerRepository $customerRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->customerRepository = self::getContainer()->get('sylius.repository.customer'); | ||
} | ||
|
||
public function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
self::ensureKernelShutdown(); | ||
} | ||
public function test_find_customer_by_email_prefix(): void | ||
{ | ||
$this->loadFixturesFromFiles(['test_find_customer_by_email_part.yaml']); | ||
|
||
$customers = $this->customerRepository->findByEmailPart('cust'); | ||
|
||
$this->assertNotEmpty($customers); | ||
$this->assertCount(1, $customers); | ||
} | ||
|
||
public function test_find_customer_by_email_sufix(): void | ||
{ | ||
$this->loadFixturesFromFiles(['test_find_customer_by_email_part.yaml']); | ||
|
||
$customers = $this->customerRepository->findByEmailPart('com'); | ||
|
||
$this->assertNotEmpty($customers); | ||
$this->assertCount(1, $customers); | ||
} | ||
|
||
public function test_find_customer_by_email_part(): void | ||
{ | ||
$this->loadFixturesFromFiles(['test_find_customer_by_email_part.yaml']); | ||
|
||
$customers = $this->customerRepository->findByEmailPart('1@'); | ||
|
||
$this->assertNotEmpty($customers); | ||
$this->assertCount(1, $customers); | ||
} | ||
|
||
public function test_find_customer_by_email_not_found(): void | ||
{ | ||
$this->loadFixturesFromFiles(['test_find_customer_by_email_part.yaml']); | ||
|
||
$customers = $this->customerRepository->findByEmailPart('cstomer'); | ||
|
||
$this->assertEmpty($customers); | ||
$this->assertCount(0, $customers); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/PHPUnit/Integration/DataFixtures/ORM/test_find_customer_by_email_part.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Tests\BitBag\SyliusBlacklistPlugin\Entity\Customer: | ||
customer_1: | ||
email: "[email protected]" | ||
firstName: "John" | ||
lastName: "Doe" | ||
gender: "u" | ||
birthday: <date_create('2021-04-03')> | ||
createdAt: <date_create('2021-04-03')> | ||
updatedAt: <date_create('2021-04-03')> | ||
fraudStatus: "neutral" |