49 lines
1.8 KiB
PHP
49 lines
1.8 KiB
PHP
<?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 hello@bitbag.io.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Tests\BitBag\OpenMarketplace\Integration\Repository;
|
|
|
|
use ApiTestCase\JsonApiTestCase;
|
|
use BitBag\OpenMarketplace\Component\Vendor\Entity\Vendor;
|
|
use Sylius\Component\Core\Model\Customer;
|
|
|
|
final class CustomerRepositoryTest extends JsonApiTestCase
|
|
{
|
|
public function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
$this->entityManager = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
$this->repository = $this->getContainer()->get('sylius.repository.customer');
|
|
}
|
|
|
|
public function test_it_finds_all_customers_of_vendor(): void
|
|
{
|
|
$this->loadFixturesFromFile('CustomerRepositoryTest/test_it_finds_all_customers_of_vendor.yaml');
|
|
|
|
$vendorOliver = $this->entityManager->getRepository(Vendor::class)->findOneBy(['slug' => 'oliver-queen-company']);
|
|
$queryBuilder = $this->repository->findVendorCustomers($vendorOliver);
|
|
|
|
$result = $queryBuilder->getQuery()->getResult();
|
|
self::assertCount(1, $result);
|
|
}
|
|
|
|
public function test_it_finds_order_for_vendor(): void
|
|
{
|
|
$this->loadFixturesFromFile('CustomerRepositoryTest/test_it_finds_order_for_vendor.yaml');
|
|
|
|
$vendorOliver = $this->entityManager->getRepository(Vendor::class)->findOneBy(['slug' => 'oliver-queen-company']);
|
|
$customer = $this->entityManager->getRepository(Customer::class)->findOneBy(['email' => 'test2@example.com']);
|
|
$result = $this->repository->findCustomerForVendor($vendorOliver, (string) $customer->getId());
|
|
|
|
self::assertEquals($customer->getId(), $result->getId());
|
|
}
|
|
}
|