Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from Zenify/console-tests
add support to Console [closes #3]
- Loading branch information
Showing
5 changed files
with
81 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
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,61 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zenify\DoctrineFilters\Tests\Console; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\Console\Application; | ||
use Symfony\Component\Console\Input\ArgvInput; | ||
use Symfony\Component\Console\Output\NullOutput; | ||
use Zenify\DoctrineFilters\Tests\ContainerFactory; | ||
|
||
|
||
final class ConsoleTest extends TestCase | ||
{ | ||
|
||
/** | ||
* @var Application | ||
*/ | ||
private $consoleApplication; | ||
|
||
/** | ||
* @var EntityManagerInterface | ||
*/ | ||
private $entityManager; | ||
|
||
|
||
protected function setUp() | ||
{ | ||
$container = (new ContainerFactory)->create(); | ||
$this->consoleApplication = $container->getByType(Application::class); | ||
$this->consoleApplication->setAutoExit(FALSE); | ||
$this->entityManager = $container->getByType(EntityManagerInterface::class); | ||
} | ||
|
||
|
||
public function test() | ||
{ | ||
$this->assertCount(0, $this->entityManager->getFilters()->getEnabledFilters()); | ||
|
||
$this->consoleApplication->run(new ArgvInput, new NullOutput); | ||
|
||
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); | ||
} | ||
|
||
|
||
public function testEnablingOnlyOnce() | ||
{ | ||
$this->assertCount(0, $this->entityManager->getFilters()->getEnabledFilters()); | ||
|
||
$this->consoleApplication->run(new ArgvInput, new NullOutput); | ||
|
||
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); | ||
|
||
$this->consoleApplication->run(new ArgvInput, new NullOutput); | ||
|
||
$this->assertCount(2, $this->entityManager->getFilters()->getEnabledFilters()); | ||
} | ||
|
||
} |
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