Skip to content

Commit

Permalink
Add test for autoloading library in sub directory
Browse files Browse the repository at this point in the history
  • Loading branch information
kenjis committed Oct 22, 2015
1 parent da5c13a commit 7ca540e
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion application/config/autoload.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
| $autoload['libraries'] = array('user_agent' => 'ua');
*/

$autoload['libraries'] = array('session', 'form_validation');
$autoload['libraries'] = array('session', 'form_validation', 'subdir/baz');


/*
Expand Down
9 changes: 9 additions & 0 deletions application/controllers/Ci_autoload_library.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class Ci_autoload_library extends CI_Controller
{
public function subdir()
{
echo $this->baz->doSomething();
}
}
9 changes: 9 additions & 0 deletions application/libraries/subdir/Baz.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

class Baz
{
public function doSomething()
{
return 'Baz something';
}
}
10 changes: 10 additions & 0 deletions application/tests/controllers/Ci_autoload_library_test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

class Ci_autoload_library_test extends TestCase
{
public function test_index()
{
$output = $this->request('GET', 'ci_autoload_library/subdir');
$this->assertEquals('Baz something', $output);
}
}

0 comments on commit 7ca540e

Please sign in to comment.