-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix repositories in context of issue llaville/php-compatinfo#372
- Loading branch information
Showing
6 changed files
with
227 additions
and
8 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,58 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of the PHP_CompatInfoDB package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Bartlett\CompatInfoDb\Tests\Database; | ||
|
||
use Bartlett\CompatInfoDb\Application\Kernel\ConsoleKernel; | ||
use Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Repository\ClassRepository; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
|
||
use Symfony\Component\Console\Input\ArrayInput; | ||
|
||
use function version_compare; | ||
use const PHP_VERSION; | ||
|
||
/** | ||
* Database functional tests for PHP_CompatInfo_Db. | ||
* | ||
* @since Release 6.4.1 | ||
* @author Laurent Laville | ||
*/ | ||
class ClassRepositoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
private EntityManagerInterface $entityManager; | ||
private ClassRepository $classRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
$kernel = new ConsoleKernel($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'tests', false); | ||
|
||
$container = $kernel->createFromInput(new ArrayInput([])); | ||
|
||
$this->entityManager = $container->get(EntityManagerInterface::class); | ||
|
||
$this->classRepository = new ClassRepository($this->entityManager); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->entityManager->close(); | ||
} | ||
|
||
public function testGetClassByName(): void | ||
{ | ||
$class = $this->classRepository->getClassByName('AMQPException', false); | ||
|
||
if (version_compare(PHP_VERSION, '7.4.0', 'ge')) { | ||
$expectedVersion = '7.4.0'; | ||
} else { | ||
$expectedVersion = '5.2.0'; | ||
} | ||
$this->assertSame($expectedVersion, $class->getPhpMin()); | ||
} | ||
} |
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,58 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of the PHP_CompatInfoDB package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Bartlett\CompatInfoDb\Tests\Database; | ||
|
||
use Bartlett\CompatInfoDb\Application\Kernel\ConsoleKernel; | ||
use Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Repository\ConstantRepository; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
|
||
use Symfony\Component\Console\Input\ArrayInput; | ||
|
||
use function version_compare; | ||
use const PHP_VERSION; | ||
|
||
/** | ||
* Database functional tests for PHP_CompatInfo_Db. | ||
* | ||
* @since Release 6.4.1 | ||
* @author Laurent Laville | ||
*/ | ||
class ConstantRepositoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
private EntityManagerInterface $entityManager; | ||
private ConstantRepository $constantRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
$kernel = new ConsoleKernel($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'tests', false); | ||
|
||
$container = $kernel->createFromInput(new ArrayInput([])); | ||
|
||
$this->entityManager = $container->get(EntityManagerInterface::class); | ||
|
||
$this->constantRepository = new ConstantRepository($this->entityManager); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->entityManager->close(); | ||
} | ||
|
||
public function testGetConstantByName(): void | ||
{ | ||
$constant = $this->constantRepository->getConstantByName('T_BAD_CHARACTER', null); | ||
|
||
if (version_compare(PHP_VERSION, '7.4.0', 'ge')) { | ||
$expectedVersion = '7.4.0beta1'; | ||
} else { | ||
$expectedVersion = '4.2.0'; | ||
} | ||
$this->assertSame($expectedVersion, $constant->getPhpMin()); | ||
} | ||
} |
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,58 @@ | ||
<?php declare(strict_types=1); | ||
/** | ||
* This file is part of the PHP_CompatInfoDB package. | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
namespace Bartlett\CompatInfoDb\Tests\Database; | ||
|
||
use Bartlett\CompatInfoDb\Application\Kernel\ConsoleKernel; | ||
use Bartlett\CompatInfoDb\Infrastructure\Persistence\Doctrine\Repository\FunctionRepository; | ||
|
||
use Doctrine\ORM\EntityManagerInterface; | ||
|
||
use Symfony\Component\Console\Input\ArrayInput; | ||
|
||
use function version_compare; | ||
use const PHP_VERSION; | ||
|
||
/** | ||
* Database functional tests for PHP_CompatInfo_Db. | ||
* | ||
* @since Release 6.4.1 | ||
* @author Laurent Laville | ||
*/ | ||
class FunctionRepositoryTest extends \PHPUnit\Framework\TestCase | ||
{ | ||
private EntityManagerInterface $entityManager; | ||
private FunctionRepository $functionRepository; | ||
|
||
protected function setUp(): void | ||
{ | ||
$kernel = new ConsoleKernel($_SERVER['APP_ENV'] ?? $_ENV['APP_ENV'] ?? 'tests', false); | ||
|
||
$container = $kernel->createFromInput(new ArrayInput([])); | ||
|
||
$this->entityManager = $container->get(EntityManagerInterface::class); | ||
|
||
$this->functionRepository = new FunctionRepository($this->entityManager); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
$this->entityManager->close(); | ||
} | ||
|
||
public function testGetFunctionByName(): void | ||
{ | ||
$constant = $this->functionRepository->getFunctionByName('random_int', null); | ||
|
||
if (version_compare(PHP_VERSION, '8.2.0', 'ge')) { | ||
$expectedVersion = '8.2.0'; | ||
} else { | ||
$expectedVersion = '7.0.2'; | ||
} | ||
$this->assertSame($expectedVersion, $constant->getPhpMin()); | ||
} | ||
} |