I load two modules.
One have a priority to 1. The other a priority of 0 but require the first module.
So the second module take the priority 1 and will be after the first module in the tree.
But, in the main tree, the key "0" (for dependency with a priority to 0) stay and have a value to null. So it's not an array and the system can't loop and sort.
$this->assert('test Modules::generateTree with some modules')
->given($mock = $this->mock)
->and($mock::setModuleLoadInfos(
'atoum',
(object) [
'priority' => 1
]
))
->and($mock::setModuleLoadInfos(
'hello-world',
(object) [
'require' => 'atoum',
'priority' => 0
//So hello-world is more priority than atoum.
//But we required atoum, so we will have a priority >= 1, not at 0.
]
))
->and($this->mock->addModule('hello-world'))
->and($this->mock->addModule('atoum'))
->variable($this->mock->generateTree())
->isNull()
->array($tree = $this->mock->getLoadTree())
->isNotEmpty()
->given(var_dump($tree))
==> Error E_WARNING in /opt/Projects-dev/bfw-v3/test/unit/src/class/Modules.php on line 152, generated by file /opt/Projects-dev/bfw-v3/vendor/bulton-fr/dependency-tree/src/Tree.php on line 101 in case 'test Modules::generateTree with some modules':
Invalid argument supplied for foreach()
==> Error E_WARNING in /opt/Projects-dev/bfw-v3/test/unit/src/class/Modules.php on line 152, generated by file /opt/Projects-dev/bfw-v3/vendor/bulton-fr/dependency-tree/src/Tree.php on line 108 in case 'test Modules::generateTree with some modules':
ksort() expects parameter 1 to be array, null given
I load two modules. One have a priority to 1. The other a priority of 0 but require the first module. So the second module take the priority 1 and will be after the first module in the tree.
But, in the main tree, the key "0" (for dependency with a priority to 0) stay and have a value to null. So it's not an array and the system can't loop and sort.
Example with unit test of https://github.com/bulton-fr/bfw