I have the following Library called Item_service:
class Item_Service {
private $items;
function __construct(Items $items)
{
$this->items = $items;
}
Where Items
is an instance of controllers/Items.php
.
In my test class called Items_test.php
i try to load the Item_service
library using the following line:
$items = $this->CI->load->library('items/Item_service');
But then I get error saying
TypeError: Argument 1 passed to Item_Service::__construct() must be an instance of Items, null given
My test class is written based on kenjis/ci-phpunit-test
.
How should I inject the controller into this library to be able to test the library? Also, can I test the controller itself? There are a lot of helper methods inside the controller.