Skip to content

Commit 8148ad8

Browse files
committed
Add tests for PR #2847
1 parent aa1b3cf commit 8148ad8

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

system/Test/bootstrap.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,14 @@
1616
defined('APPPATH') || define('APPPATH', realpath($paths->appDirectory) . DIRECTORY_SEPARATOR);
1717
defined('WRITEPATH') || define('WRITEPATH', realpath($paths->writableDirectory) . DIRECTORY_SEPARATOR);
1818
defined('SYSTEMPATH') || define('SYSTEMPATH', realpath($paths->systemDirectory) . DIRECTORY_SEPARATOR);
19+
defined('VIEWPATH') || define('VIEWPATH', realpath($paths->viewDirectory) . DIRECTORY_SEPARATOR);
1920
defined('ROOTPATH') || define('ROOTPATH', realpath(APPPATH . '../') . DIRECTORY_SEPARATOR);
2021
defined('CIPATH') || define('CIPATH', realpath(SYSTEMPATH . '../') . DIRECTORY_SEPARATOR);
2122
defined('FCPATH') || define('FCPATH', realpath(PUBLICPATH) . DIRECTORY_SEPARATOR);
2223
defined('TESTPATH') || define('TESTPATH', realpath(HOMEPATH . 'tests/') . DIRECTORY_SEPARATOR);
2324
defined('SUPPORTPATH') || define('SUPPORTPATH', realpath(TESTPATH . '_support/') . DIRECTORY_SEPARATOR);
2425
defined('COMPOSER_PATH') || define('COMPOSER_PATH', realpath(HOMEPATH . 'vendor/autoload.php'));
26+
defined('VENDORPATH') || define('VENDORPATH', realpath(HOMEPATH . 'vendor') . DIRECTORY_SEPARATOR);
2527

2628
// Load Common.php from App then System
2729
if (file_exists(APPPATH . 'Common.php'))

tests/system/Debug/ExceptionsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,26 @@ public function testNew()
77
$actual = new Exceptions(new \Config\Exceptions(), \Config\Services::request(), \Config\Services::response());
88
$this->assertInstanceOf(Exceptions::class, $actual);
99
}
10+
11+
/**
12+
* @dataProvider dirtyPathsProvider
13+
*/
14+
public function testCleanPaths($file, $expected)
15+
{
16+
$this->assertEquals($expected, Exceptions::cleanPath($file));
17+
}
18+
19+
public function dirtyPathsProvider()
20+
{
21+
$ds = DIRECTORY_SEPARATOR;
22+
23+
return [
24+
[APPPATH . 'Config' . $ds . 'App.php', 'APPPATH' . $ds . 'Config' . $ds . 'App.php'],
25+
[APPPATH . 'Views' . $ds . 'welcome_message.php', 'VIEWPATH' . $ds . 'welcome_message.php'],
26+
[SYSTEMPATH . 'CodeIgniter.php', 'SYSTEMPATH' . $ds . 'CodeIgniter.php'],
27+
[VIEWPATH . 'errors' . $ds . 'html' . $ds . 'error_exception.php', 'VIEWPATH' . $ds . 'errors' . $ds . 'html' . $ds . 'error_exception.php'],
28+
[VENDORPATH . 'autoload.php', 'VENDORPATH' . $ds . 'autoload.php'],
29+
[FCPATH . 'index.php', 'FCPATH' . $ds . 'index.php'],
30+
];
31+
}
1032
}

0 commit comments

Comments
 (0)