IOP-Patho/vendor/codeception/base/tests/unit/Codeception/Lib/DiTest.php

51 lines
1.7 KiB
PHP
Raw Permalink Normal View History

2025-07-17 08:28:28 +00:00
<?php
namespace Codeception\Lib;
class DiTest extends \Codeception\Test\Unit
{
/**
* @var Di
*/
protected $di;
protected function setUp()
{
$this->di = new Di();
}
protected function injectionShouldFail($msg = '')
{
$this->setExpectedException('Codeception\Exception\InjectionException', $msg);
}
public function testFailDependenciesCyclic()
{
require_once codecept_data_dir().'FailDependenciesCyclic.php';
$this->injectionShouldFail(
'Failed to resolve cyclic dependencies for class \'FailDependenciesCyclic\IncorrectDependenciesClass\''
);
$this->di->instantiate('FailDependenciesCyclic\IncorrectDependenciesClass');
}
public function testFailDependenciesInChain()
{
require_once codecept_data_dir().'FailDependenciesInChain.php';
$this->injectionShouldFail('Failed to resolve dependency \'FailDependenciesInChain\AnotherClass\'');
$this->di->instantiate('FailDependenciesInChain\IncorrectDependenciesClass');
}
public function testFailDependenciesNonExistent()
{
require_once codecept_data_dir().'FailDependenciesNonExistent.php';
$this->injectionShouldFail('Class FailDependenciesNonExistent\NonExistentClass does not exist');
$this->di->instantiate('FailDependenciesNonExistent\IncorrectDependenciesClass');
}
public function testFailDependenciesPrimitiveParam()
{
require_once codecept_data_dir().'FailDependenciesPrimitiveParam.php';
$this->injectionShouldFail('Parameter \'required\' must have default value');
$this->di->instantiate('FailDependenciesPrimitiveParam\IncorrectDependenciesClass');
}
}