This repository has been archived by the owner on Aug 9, 2022. It is now read-only.
-
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
1 parent
d17823e
commit 20ab986
Showing
5 changed files
with
81 additions
and
1 deletion.
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,28 @@ | ||
<?php | ||
|
||
namespace Smart\ParameterBundle\Manager; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Smart\ParameterBundle\Entity\Parameter; | ||
|
||
/** | ||
* @author Mathieu Ducrot <[email protected]> | ||
*/ | ||
class ParameterManager | ||
{ | ||
private EntityManagerInterface $entityManager; | ||
|
||
public function __construct(EntityManagerInterface $entityManager) | ||
{ | ||
$this->entityManager = $entityManager; | ||
} | ||
|
||
/** | ||
* Create the Parameter | ||
*/ | ||
public function create(Parameter $parameter): void | ||
{ | ||
$this->entityManager->persist($parameter); | ||
$this->entityManager->flush(); | ||
} | ||
} |
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,40 @@ | ||
<?php | ||
|
||
namespace Smart\ParameterBundle\Tests\Manager; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use Smart\ParameterBundle\Entity\Parameter; | ||
use Smart\ParameterBundle\Manager\ParameterManager; | ||
use Smart\ParameterBundle\Tests\AbstractWebTestCase; | ||
|
||
/** | ||
* @author Mathieu Ducrot <[email protected]> | ||
* | ||
* vendor/bin/phpunit tests/Manager/ParameterManagerTest.php | ||
*/ | ||
class ParameterManagerTest extends AbstractWebTestCase | ||
{ | ||
private ?ParameterManager $parameterManager; | ||
private ?EntityManagerInterface $entityManager; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$container = self::$container; | ||
$this->parameterManager = $container->get(ParameterManager::class); | ||
$this->entityManager = $container->get(EntityManagerInterface::class); | ||
} | ||
|
||
public function testCrate(): void | ||
{ | ||
$parameter = new Parameter(); | ||
$parameter->setCode('test'); | ||
$parameter->setValue('value'); | ||
|
||
$repository = $this->entityManager->getRepository(Parameter::class); | ||
$nbParameter = $repository->count([]); | ||
$this->parameterManager->create($parameter); | ||
$this->assertSame($nbParameter + 1, $repository->count([])); | ||
} | ||
} |
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