Created
March 22, 2010 19:26
-
-
Save lonnieezell/340436 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <IfModule mod_rewrite.c> | |
| RewriteEngine On | |
| RewriteCond %{REQUEST_FILENAME} !-f | |
| RewriteCond %{REQUEST_FILENAME} !-d | |
| RewriteRule (.*) index.php/$1 [L] | |
| </IfModule> | |
| <IfModule !mod_rewrite.c> | |
| ErrorDocument 404 /index.php | |
| </IfModule> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class Assets_library_test extends CodeIgniterUnitTestCase { | |
| function testAutoDiscoverFeedTag() { | |
| $this->ci->load->library('Assets'); | |
| $tag = $this->ci->assets->auto_discovery_tag('rss', 'http://feeds.test.com'); | |
| $this->assertTrue(is_string($tag)); | |
| } | |
| //--------------------------------------------------------------- | |
| function testImageTag() { | |
| $this->ci->load->library('Assets'); | |
| $tag = $this->ci->assets->image_tag('test'); | |
| $this->assertTrue(is_string($tag) && !empty($tag)); | |
| } | |
| //--------------------------------------------------------------- | |
| function testImageTagWithSize() { | |
| $this->ci->load->library('Assets'); | |
| $tag = $this->ci->assets->image_tag('test', array('size'=>'150x25')); | |
| $this->assertTrue(is_string($tag) && !empty($tag)); | |
| } | |
| //--------------------------------------------------------------- | |
| function testJSTag() { | |
| $this->ci->load->library('Assets'); | |
| $tag = $this->ci->assets->js_tag('test'); | |
| $this->assertTrue(is_string($tag) && !empty($tag)); | |
| } | |
| //--------------------------------------------------------------- | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <style type="text/css"> | |
| body { padding: 0; margin: 0; font:13px/18px Arial, Helvetica, sans-serif; } | |
| #header { min-height: 47px; background: #2b2b2b url(../../docs/bonfire/images/logo.gif) 100px 15px no-repeat; color: #fff; margin-bottom: 20px; padding: 17px 0 0 230px; } | |
| a.submit, input[type=submit] { width: 8em; background-color: #4b4b4b; border: 1px outset #6b6b6b; color: #ccc; cursor: pointer; -moz-border-radius: 5px; -webkit-border-radius: 5px; padding: 5px 10px; text-decoration: none; } | |
| a.submit:hover, input[type=submit]:hover { border-style: inset; } | |
| form { width: auto; display: inline-block; } | |
| #header span { margin-left: 50px; } | |
| #header input[type=text] { border: 1px inset #6b6b6b; padding: 4px 7px; -moz-border-radius: 5px; -webkit-border-radius: 5px; margin-right: 7px; } | |
| #content { padding: 0 30px 20px 100px; } | |
| </style> | |
| <div id="header"> | |
| <a href="?all" class="submit">All</a> | |
| <a href="?controllers" class="submit">Controllers</a> | |
| <a href="?models" class="submit">Models</a> | |
| <a href="?views" class="submit">Views</a> | |
| <span>Run A Test: | |
| <form action="" method="get"><input type="text" name="test" value="" /><input type="submit" value="Run" /></form> | |
| </span> | |
| </div> | |
| <div id="content"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| SimpleTest + CodeIgniter | |
| test.php | |
| the test runner - loads all needed files, | |
| integrates with CodeIgniter and runs the tests | |
| by Jamie Rumbelow | |
| http://jamierumbelow.net/ | |
| The following modifications were by Lonnie Ezell: | |
| - modified paths to fit the bonfire setup | |
| - added the ability to store library tests in the controllers test folder. | |
| */ | |
| //Configure and load files | |
| define('ROOT', dirname(__FILE__) . '/'); | |
| require_once ROOT . 'codeigniter/test/unit_tester.php'; | |
| require_once ROOT . 'codeigniter/test/web_tester.php'; | |
| require_once ROOT . 'codeigniter/test/reporter.php'; | |
| function add_test($file, &$test) { | |
| $implementation = ''; | |
| if (preg_match('/_controller/', $file)) { | |
| $controller = preg_replace('#' . ROOT . 'bonfire/tests/controllers/([a-zA-Z0-9_\-])_controller_test.php#', '$1', $file); | |
| $implementation = ROOT . 'bonfire/controllers/'.$controller.'.php'; | |
| } elseif (preg_match('/_library/', $file)) { | |
| $model = preg_replace('#' . ROOT . 'bonfire/tests/controllers/([a-zA-Z0-9_\-])_library_test.php#', '$1', $file); | |
| $implementation = ROOT . 'bonfire/libraries/'.$model.'_model.php'; | |
| } elseif (preg_match('/_model/', $file)) { | |
| $model = preg_replace('#' . ROOT . 'bonfire/tests/models/([a-zA-Z0-9_\-])_model_test.php#', '$1', $file); | |
| $implementation = ROOT . 'bonfire/models/'.$model.'_model.php'; | |
| } elseif (preg_match('/_view/', $file)) { | |
| $view = preg_replace('#' . ROOT . 'bonfire/tests/views/([a-zA-Z0-9_\-])_view_test.php#', '$1', $file); | |
| $view = implode('/', explode('_', $view)); | |
| $implementation = ROOT . 'bonfire/views/'.$view.'.php'; | |
| } | |
| if (file_exists($implementation)) { | |
| require_once($implementation); | |
| } | |
| $test->addFile($file); | |
| } | |
| //--------------------------------------------------------------- | |
| class CodeIgniterUnitTestCase extends UnitTestCase { | |
| protected $ci; | |
| public function __construct() { | |
| parent::UnitTestCase(); | |
| $this->ci =& get_instance(); | |
| } | |
| } | |
| //--------------------------------------------------------------- | |
| class CodeIgniterWebTestCase extends WebTestCase { | |
| protected $ci; | |
| public function __construct() { | |
| parent::WebTestCase(); | |
| $this->ci =& get_instance(); | |
| } | |
| } | |
| //--------------------------------------------------------------- | |
| //Capture CodeIgniter output, discard and load system into $CI variable | |
| ob_start(); | |
| include(ROOT . 'index.php'); | |
| $CI =& get_instance(); | |
| ob_end_clean(); | |
| //Setup the test suite | |
| $test =& new TestSuite(); | |
| $test->_label = 'Bonfire Application Test Suite'; | |
| if (!isset($_GET['test'])) { | |
| //What are we testing? | |
| $files = array(); | |
| if (isset($_GET['controllers'])) { | |
| $files = @scandir(ROOT . 'bonfire/tests/controllers'); | |
| } elseif (isset($_GET['models'])) { | |
| $files = @scandir(ROOT . 'bonfire/tests/models'); | |
| } elseif (isset($_GET['models'])) { | |
| $files = @scandir(ROOT . 'bonfire/tests/views'); | |
| } elseif (isset($_GET['all'])) { | |
| $files = @scandir(ROOT . 'bonfire/tests/controllers'); | |
| $files = array_merge($files, @scandir(ROOT . 'bonfire/tests/models')); | |
| $files = array_merge($files, @scandir(ROOT . 'bonfire/tests/views')); | |
| } else { | |
| //Use all by default | |
| $files = @scandir(ROOT . 'bonfire/tests/controllers'); | |
| $files = array_merge($files, @scandir(ROOT . 'bonfire/tests/models')); | |
| $files = array_merge($files, @scandir(ROOT . 'bonfire/tests/views')); | |
| } | |
| //Remove ., .. and any .whatever files, and add the full path | |
| function prepare_array($value, $key) { | |
| global $files; | |
| if (preg_match('/^\./', $value)) { unset($files[$key]); } | |
| if (preg_match('/_model/', $value)) { $files[$key] = ROOT . 'bonfire/tests/models/' . $value; } | |
| if (preg_match('/_controller/', $value)) { $files[$key] = ROOT . 'bonfire/tests/controllers/' . $value; } | |
| if (preg_match('/_library/', $value)) { $files[$key] = ROOT . 'bonfire/tests/controllers/' . $value; } | |
| if (preg_match('/_view/', $value)) { $files[$key] = ROOT . 'bonfire/tests/views/' . $value; } | |
| } | |
| array_walk($files, 'prepare_array'); | |
| //Add each file to the test suite | |
| foreach ($files as $file) { | |
| add_test($file, &$test); | |
| } | |
| } else { | |
| add_test(ROOT . 'bonfire/tests/' . $file, &$test); | |
| } | |
| // Include the gui | |
| include(ROOT . 'codeigniter/test/custom_test_gui.php'); | |
| //Run tests! | |
| $test->run(new HtmlReporter()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment