Skip to content

Commit

Permalink
OP-466 - Create and fix phpUnit
Browse files Browse the repository at this point in the history
  • Loading branch information
JanPalen committed Aug 12, 2024
1 parent 2555ba4 commit c16bfe6
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ public function SetUp(): void
{
parent::SetUp();

$this->automaticBlacklistingConfigurationRepository = self::$container->get('bitbag_sylius_blacklist_plugin.repository.automatic_blacklisting_configuration');
$this->channelRepository = self::$container->get('sylius.repository.channel');
$this->automaticBlacklistingConfigurationRepository = self::getContainer()->get('bitbag_sylius_blacklist_plugin.repository.automatic_blacklisting_configuration');
$this->channelRepository = self::getContainer()->get('sylius.repository.channel');
}

public function tearDown(): void
Expand Down
71 changes: 71 additions & 0 deletions tests/PHPUnit/Integration/CustomerRepositoryTest.php
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);
}
}
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"

0 comments on commit c16bfe6

Please sign in to comment.