Repository navigation
Expand file tree
/
Copy pathDiTest.php
More file actions
48 lines (41 loc) · 1.68 KB
/
Copy pathDiTest.php
File metadata and controls
48 lines (41 loc) · 1.68 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?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');
}
}