I have a code igniter project and I installed phpspec. My problem is that when I run a test on my class, it throws an error that it cannot find that class's base class (which is automatically loaded by the code igniter framework) namely "Class 'CI_Controller' not found".
I tried manually including the path to the base class and removing the line namespace controllers;
which seems to fix that problem. But now my phpspec test is failing saying that class controllers\Calculator does not exist
.
Here is how I have it set up:
My class in src > controllers > Calculator.php:
<?php
//I had to remove the following line for my app to work:
//namespace controllers;
class Calculator extends CI_Controller {...}
My test in spec > controllers > CalculatorSpec.php:
<?php
namespace spec\controllers;
use PhpSpec\ObjectBehavior;
use Prophecy\Argument;
//I had to add this line to fix my first problem
include_once '/Users/bradleytrager/Desktop/Workspace/code-ignitor-calculator/system/core/Controller.php';
class CalculatorSpec extends ObjectBehavior
{
function it_is_initializable()
{
$this->shouldHaveType('controllers\Calculator');
}
}
Can anyone help me to get this to work?