public function testFileExtensions() { $this->assertEquals('html', Utilities::getFileExtension('/some/dir/test.html')); $this->assertEquals('html', Utilities::getFileExtension('test.html')); $this->assertEquals('html', Utilities::getFileExtension('.html')); $this->assertEquals('html', Utilities::getFileExtension('html')); $this->assertEquals('php', Utilities::getFileExtension('test.html.php')); $exts = array('htm' => array('text/html', 'html'), 'css' => array('text/css', 'css'), 'html' => array('text/html', 'html'), 'js' => array('application/javascript', 'js'), 'json' => array('application/json', 'json'), 'rss' => array('application/rss+xml', 'rss'), 'atom' => array('application/atom+xml', 'atom'), 'xhtml' => array('application/xhtml+xml', 'xhtml'), 'xml' => array('application/xml', 'xml'), 'jpg' => array('image/jpeg', 'jpeg'), 'gif' => array('image/gif', 'gif'), 'jpeg' => array('image/jpeg', 'jpeg'), 'png' => array('image/png', 'png'), 'txt' => array('text/plain', 'txt'), 'unknown' => array('text/plain', 'txt')); foreach ($exts as $ext => $a) { list($mime, $ext2) = $a; $actualMime = Utilities::getContentType($ext); $this->assertEquals($mime, $actualMime); $this->assertEquals($ext2, Utilities::getExtension($actualMime)); } $this->assertEquals(null, Utilities::getExtension('text/unknown')); }
function loadHelpers($type) { if ($type === 'all') { $files = scandir($this->quantum_root . 'system/helpers/'); //var_dump($files); foreach ($files as $file) { if (Utilities::getExtension($file) == 'php') { include_once $this->quantum_root . 'system/helpers/' . $file; } } return true; } else { $file = $type; include_once $this->quantum_root . 'app/helpers/' . $file; return true; } }