I'm new to CI and am struggling to get my head around it.
I'm familiar with Laravel and Symfony and I'm finding it very difficult to test CI code.
I'm considering the service locator pattern to try and work around the dependency injection limitations, but right now I'm struggling with autoloading.
Let's say that I have a model like this:
<?php
class FooModel extends CI_Model
{
public function __construct()
{
parent::__construct();
$this->load->library('alertnotificationservice');
}
}
I want to write a test that looks like this:
<?php
namespace Test\AlertNotification;
// extends TestCase and offers reflection helper methods
use Test\TestBase;
class PublishModelTest extends TestBase
{
public function test_my_method()
{
$objectUnderTest = new \FooModel();
}
}
When I run my test I get the error Error: Class 'CI_Model' not found
.
CodeIgnitor doesn't use composer.
I could manual include this file (and somehow I expect this framework would find that an acceptable practice)
What is the "proper" way to get the autoloading to happen so that I can run my tests?
Aucun commentaire:
Enregistrer un commentaire