[Arbiter-commits] arbiter/use_cases all_tests.php, NONE, 1.1 repository_use_case.php, NONE, 1.1 use
Status: Pre-Alpha
Brought to you by:
lastcraft
|
From: Marcus B. <las...@us...> - 2007-03-11 19:33:12
|
Update of /cvsroot/arbiter/arbiter/use_cases In directory sc8-pr-cvs11.sourceforge.net:/tmp/cvs-serv23253/use_cases Added Files: all_tests.php repository_use_case.php use_case.php Log Message: Copying over previous work on the PHP version --- NEW FILE: all_tests.php --- <?php require_once('simpletest/web_tester.php'); // Need a symlink to SimpleTest. require_once('simpletest/reporter.php'); require_once('simpletest/autorun.php'); class AllTests extends GroupTest { function AllTests() { $this->GroupTest('All tests for Arbiter ' . implode('', file('../VERSION'))); $this->addTestFile('repository_use_case.php'); } } ?> --- NEW FILE: repository_use_case.php --- <?php require_once(dirname(__FILE__) . '/use_case.php'); class RepositoryManagement extends UseCase { function getSampleFile($sample_name) { return dirname(__FILE__) . "/samples/$sample_name"; } function testServerStartsEmpty() { $this->get($this->getServerUri()); $this->assertWantedPattern('/Waiting for first document/i'); } function testServerDisallowsBadMimeType() { $this->get($this->getServerUri()); $this->setField('document', $this->getSampleFile('requirements.ini')); $this->clickSubmitByName('action'); $this->assertWantedPattern('/document is not a valid .rtf file/'); } function testServerAllowsTitleOnlyUpload() { $this->get($this->getServerUri()); $this->setField('document', $this->getSampleFile('title_only.openoffice1.rtf')); $this->clickSubmitByName('action'); $this->assertWantedPattern('/Title Only/'); $this->clickLink('Title Only'); $this->assertMime(array('application/octet-stream', 'application/msword')); $this->assertWantedPattern('/This is an empty requirements document/'); } } ?> --- NEW FILE: use_case.php --- <?php class UseCase extends WebTestCase { function setUp() { $this->deleteConfiguration(); $this->install(); } function tearDown() { $this->uninstall(); } function deleteConfiguration() { } function install() { } function uninstall() { } function getSelfUri() { if (isset($_SERVER['SCRIPT_URI'])) { return $_SERVER['SCRIPT_URI']; } if (isset($_SERVER['HTTP_HOST']) && isset($_SERVER['PHP_SELF'])) { return 'http://'. $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']; } return false; } function getServerUri() { static $has_warned = false; if (isset($argv[1])) { return $argv[1]; } if ($self = $this->getSelfUri()) { return preg_replace('|arbiter/test/.*|', 'arbiter/server/index.php', $self); } if (! $has_warned) { $has_warned = true; trigger_error('Must have server URL as argument'); } } } ?> |