more tests
This commit is contained in:
		
							parent
							
								
									d2cad188b4
								
							
						
					
					
						commit
						ead9e27dea
					
				@ -10,7 +10,6 @@ require_once('simpletest/web_tester.php');
 | 
			
		||||
require_once('simpletest/unit_tester.php');
 | 
			
		||||
require_once('simpletest/reporter.php');
 | 
			
		||||
 | 
			
		||||
define('TEST_BASE', "http://shimmie.shishnet.org/branch_2.3/index.php?q=");
 | 
			
		||||
define('USER_NAME', "test");
 | 
			
		||||
define('USER_PASS', "test");
 | 
			
		||||
define('ADMIN_NAME', "demo");
 | 
			
		||||
@ -18,7 +17,7 @@ define('ADMIN_PASS', "demo");
 | 
			
		||||
 | 
			
		||||
class ShimmieWebTestCase extends WebTestCase {
 | 
			
		||||
	protected function get_page($page) {
 | 
			
		||||
		$this->get(TEST_BASE.'/'.$page);
 | 
			
		||||
		$this->get($_SERVER["HTTP_HOST"].'/'.make_link($page));
 | 
			
		||||
	}
 | 
			
		||||
	protected function log_in_as_user() {
 | 
			
		||||
        $this->get_page('post/list');
 | 
			
		||||
@ -49,7 +48,7 @@ class ShimmieWebTestCase extends WebTestCase {
 | 
			
		||||
		$this->assertText("Upload");
 | 
			
		||||
		$this->setField("data0", $filename);
 | 
			
		||||
		$this->setField("tags", $tags);
 | 
			
		||||
		$this->click("Post");
 | 
			
		||||
		$this->clickSubmitById("uploadbutton");
 | 
			
		||||
 | 
			
		||||
		$raw_headers = $this->getBrowser()->getHeaders();
 | 
			
		||||
		$headers = explode("\n", $raw_headers);
 | 
			
		||||
@ -74,8 +73,9 @@ class ShimmieWebTestCase extends WebTestCase {
 | 
			
		||||
 | 
			
		||||
class TestFinder extends TestSuite {
 | 
			
		||||
	function TestFinder($hint) {
 | 
			
		||||
		if(strpos($hint, "..") !== FALSE) return;
 | 
			
		||||
		$dir = "*";
 | 
			
		||||
		if(file_exists("ext/$hint/test.php")) $dir = $hint; // FIXME: check for ..
 | 
			
		||||
		if(file_exists("ext/$hint/test.php")) $dir = $hint;
 | 
			
		||||
		$this->TestSuite('All tests');
 | 
			
		||||
		foreach(glob("ext/$dir/test.php") as $file) {
 | 
			
		||||
			$this->addFile($file);
 | 
			
		||||
 | 
			
		||||
@ -1,28 +0,0 @@
 | 
			
		||||
<?php
 | 
			
		||||
#require_once('lib/simpletest/autorun.php');
 | 
			
		||||
require_once('simpletest/web_tester.php');
 | 
			
		||||
#require_once('simpletest/unit_tester.php'); # unit tests require shimmie to be running
 | 
			
		||||
require_once('simpletest/reporter.php');
 | 
			
		||||
 | 
			
		||||
chdir("../../");
 | 
			
		||||
require_once('config.php');
 | 
			
		||||
 | 
			
		||||
class SectionReporter extends TextReporter {
 | 
			
		||||
	function paintGroupStart($name, $size) {
 | 
			
		||||
		parent::paintGroupStart($name, $size);
 | 
			
		||||
		print "\n** $name\n";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
class AllTests extends TestSuite {
 | 
			
		||||
	function AllTests() {
 | 
			
		||||
		$this->TestSuite('All tests');
 | 
			
		||||
		foreach(glob("ext/*/test.php") as $file) {
 | 
			
		||||
			$this->addFile($file);
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$all = new AllTests();
 | 
			
		||||
$all->run(new SectionReporter());
 | 
			
		||||
?>
 | 
			
		||||
@ -1,11 +1,51 @@
 | 
			
		||||
<?php
 | 
			
		||||
class CommentListTest extends ShimmieWebTestCase {
 | 
			
		||||
	function testCommentsPage() {
 | 
			
		||||
        $this->get_page('comment/list');
 | 
			
		||||
        $this->assertTitle('Comments');
 | 
			
		||||
		$this->log_in_as_user();
 | 
			
		||||
		$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
 | 
			
		||||
 | 
			
		||||
        $this->get_page('comment/list/2');
 | 
			
		||||
        $this->assertTitle('Comments');
 | 
			
		||||
		# a good comment
 | 
			
		||||
		$this->get_page("post/view/$image_id");
 | 
			
		||||
		$this->setField('comment', "Test Comment ASDFASDF");
 | 
			
		||||
		$this->click("Post Comment");
 | 
			
		||||
		$this->assertText("ASDFASDF");
 | 
			
		||||
 | 
			
		||||
		# dupe
 | 
			
		||||
		$this->get_page("post/view/$image_id");
 | 
			
		||||
		$this->setField('comment', "Test Comment ASDFASDF");
 | 
			
		||||
		$this->click("Post Comment");
 | 
			
		||||
		$this->assertText("try and be more original");
 | 
			
		||||
 | 
			
		||||
		# empty comment
 | 
			
		||||
		$this->get_page("post/view/$image_id");
 | 
			
		||||
		$this->setField('comment', "");
 | 
			
		||||
		$this->click("Post Comment");
 | 
			
		||||
		$this->assertText("Comments need text...");
 | 
			
		||||
 | 
			
		||||
		# whitespace is still empty...
 | 
			
		||||
		$this->get_page("post/view/$image_id");
 | 
			
		||||
		$this->setField('comment', " \t\r\n");
 | 
			
		||||
		$this->click("Post Comment");
 | 
			
		||||
		$this->assertText("Comments need text...");
 | 
			
		||||
 | 
			
		||||
		# repetitive (gzip gives 10x improvement)
 | 
			
		||||
		$this->get_page("post/view/$image_id");
 | 
			
		||||
		$this->setField('comment', str_repeat("U", 5000));
 | 
			
		||||
		$this->click("Post Comment");
 | 
			
		||||
		$this->assertText("Comment too repetitive~");
 | 
			
		||||
 | 
			
		||||
		$this->log_out();
 | 
			
		||||
 | 
			
		||||
		$this->get_page('comment/list');
 | 
			
		||||
		$this->assertTitle('Comments');
 | 
			
		||||
		$this->assertText('ASDFASDF');
 | 
			
		||||
 | 
			
		||||
		$this->get_page('comment/list/2');
 | 
			
		||||
		$this->assertTitle('Comments');
 | 
			
		||||
 | 
			
		||||
		$this->log_in_as_admin();
 | 
			
		||||
		$this->delete_image($image_id);
 | 
			
		||||
		$this->log_out();
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
?>
 | 
			
		||||
 | 
			
		||||
@ -120,7 +120,7 @@ class CommentListTheme extends Themelet {
 | 
			
		||||
			<input type='hidden' name='image_id' value='$i_image_id' />
 | 
			
		||||
			<input type='hidden' name='hash' value='$hash' />
 | 
			
		||||
			<textarea name='comment' rows='5' cols='50'></textarea>
 | 
			
		||||
			<br><input type='submit' value='Post' />
 | 
			
		||||
			<br><input type='submit' value='Post Comment' />
 | 
			
		||||
			</form>
 | 
			
		||||
			";
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
@ -1,6 +1,10 @@
 | 
			
		||||
<?php
 | 
			
		||||
class IndexTest extends ShimmieWebTestCase {
 | 
			
		||||
	function testIndexPage() {
 | 
			
		||||
		$this->get_page('post/list');
 | 
			
		||||
		$this->assertTitle("Welcome to Shimmie ".VERSION);
 | 
			
		||||
		$this->assertNoText("Prev | Index | Next");
 | 
			
		||||
 | 
			
		||||
		$this->log_in_as_user();
 | 
			
		||||
		$image_id = $this->post_image("ext/simpletest/data/pbx_screenshot.jpg", "pbx computer screenshot");
 | 
			
		||||
		$this->log_out();
 | 
			
		||||
 | 
			
		||||
@ -40,7 +40,7 @@ class UploadTheme extends Themelet {
 | 
			
		||||
					$upload_list
 | 
			
		||||
					<tr><td>Tags</td><td colspan='3'><input id='tagBox' name='tags' type='text' value='tagme' autocomplete='off'></td></tr>
 | 
			
		||||
					<tr><td>Source</td><td colspan='3'><input name='source' type='text'></td></tr>
 | 
			
		||||
					<tr><td colspan='4'><input type='submit' value='Post'></td></tr>
 | 
			
		||||
					<tr><td colspan='4'><input id='uploadbutton' type='submit' value='Post'></td></tr>
 | 
			
		||||
				</table>
 | 
			
		||||
			</form>
 | 
			
		||||
			<div id='upload_completions' style='clear: both;'><small>(Max file size is $max_kb)</small></div>
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user