-
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.
- Loading branch information
Showing
2 changed files
with
128 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
<?php | ||
|
||
namespace Prokl\ServiceProvider\Tests\Cases; | ||
|
||
use Exception; | ||
use Prokl\BitrixTestingTools\Base\BitrixableTestCase; | ||
use Prokl\ServiceProvider\ServiceProvider; | ||
use Prokl\ServiceProvider\Services\AppKernel; | ||
use Prokl\ServiceProvider\Utils\Loaders\PhpLoaderSettingsBitrix; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Config\FileLocator; | ||
|
||
/** | ||
* Class PhpLoaderSettingsBitrixTest | ||
* @package Prokl\ServiceProvider\Tests\Cases | ||
* | ||
* @since 13.07.2021 | ||
*/ | ||
class PhpLoaderSettingsBitrixTest extends BitrixableTestCase | ||
{ | ||
/** | ||
* @var PhpLoaderSettingsBitrix $obTestObject | ||
*/ | ||
protected $obTestObject; | ||
|
||
/** | ||
* @var ContainerBuilder $dummyContainer | ||
*/ | ||
private $dummyContainer; | ||
|
||
/** | ||
* @var AppKernel | ||
*/ | ||
private $kernel; | ||
|
||
/** | ||
* @var string $pathYamlConfig Путь к конфигу. | ||
*/ | ||
private $fixture = '/../../../../tests/Fixtures/Settings'; | ||
|
||
/** | ||
* @var string $pathYamlConfig Путь к конфигу. | ||
*/ | ||
private $pathYamlConfig = '../../../../tests/Fixtures/config/test_container.yaml'; | ||
|
||
/** | ||
* @inheritDoc | ||
* @throws Exception | ||
*/ | ||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$_ENV['DEBUG'] = true; | ||
$this->container = new ServiceProvider( | ||
$this->pathYamlConfig | ||
); | ||
|
||
$this->dummyContainer = $this->container->container(); | ||
|
||
$this->kernel = $this->dummyContainer->get('kernel'); | ||
$locator = new FileLocator($this->kernel); | ||
|
||
$this->obTestObject = new PhpLoaderSettingsBitrix( | ||
$this->dummyContainer, | ||
$locator | ||
); | ||
} | ||
|
||
/** | ||
* supports(). | ||
* | ||
* @param string $file Файл. | ||
* | ||
* @return void | ||
* | ||
* @dataProvider dataProviderValidBitrixConfigFilename | ||
*/ | ||
public function testSupports(string $file) : void | ||
{ | ||
$result = $this->obTestObject->supports($file); | ||
|
||
$this->assertTrue($result, 'Валидный конфиг не прошел проверку.'); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function dataProviderValidBitrixConfigFilename() : array | ||
{ | ||
return [ | ||
[$_SERVER['DOCUMENT_ROOT'] . $this->fixture . '/.settings.php'], | ||
[$_SERVER['DOCUMENT_ROOT'] . $this->fixture . '/.settings_extra.php'] | ||
]; | ||
} | ||
|
||
/** | ||
* supports(). Невалидные файлы. | ||
* | ||
* @param string $file Файл. | ||
* | ||
* @return void | ||
* | ||
* @dataProvider dataProviderInvalidBitrixConfigFilename | ||
*/ | ||
public function testSupportsInvalid(string $file) : void | ||
{ | ||
$result = $this->obTestObject->supports($file); | ||
|
||
$this->assertFalse($result, 'Невалидный конфиг прошел проверку.'); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
public function dataProviderInvalidBitrixConfigFilename() : array | ||
{ | ||
return [ | ||
[$_SERVER['DOCUMENT_ROOT'] . $this->fixture . '/.config.php'], | ||
[$_SERVER['DOCUMENT_ROOT'] . $this->fixture . '/.settings.html'], | ||
[$_SERVER['DOCUMENT_ROOT'] . $this->fixture . '/.settings_extra'], | ||
]; | ||
} | ||
} |