mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
50 lines
1.2 KiB
PHP
50 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace Controller;
|
|
|
|
use Chill\MainBundle\Entity\Address;
|
|
use Chill\MainBundle\Repository\AddressRepository;
|
|
use Chill\MainBundle\Test\PrepareClientTrait;
|
|
use Doctrine\ORM\EntityManagerInterface;
|
|
use Symfony\Bundle\FrameworkBundle\KernelBrowser;
|
|
|
|
class AddressControllerTest extends \Symfony\Bundle\FrameworkBundle\Test\WebTestCase
|
|
{
|
|
private KernelBrowser $client;
|
|
|
|
use PrepareClientTrait;
|
|
|
|
public function setUp()
|
|
{
|
|
self::bootKernel();
|
|
$this->client = $this->getClientAuthenticated();
|
|
}
|
|
|
|
/**
|
|
* @dataProvider generateAddressIds
|
|
* @param int $addressId
|
|
*/
|
|
public function testDuplicate(int $addressId)
|
|
{
|
|
$this->client->request('POST', "/api/1.0/main/address/$addressId/duplicate.json");
|
|
|
|
$this->assertResponseIsSuccessful('test that duplicate is successful');
|
|
}
|
|
|
|
public function generateAddressIds()
|
|
{
|
|
self::bootKernel();
|
|
$em = self::$container->get(EntityManagerInterface::class);
|
|
|
|
$qb = $em->createQueryBuilder();
|
|
$addresses = $qb->select('a')->from(Address::class, 'a')
|
|
->setMaxResults(2)
|
|
->getQuery()
|
|
->getResult();
|
|
|
|
foreach ($addresses as $a) {
|
|
yield [ $a->getId() ];
|
|
}
|
|
}
|
|
}
|