Permalink
Browse files

SOAP tests: improved bootstrap file

New available options
- user name, password and e-mail
- project id

Comments have been added to bootstrap.php.sample file.
  • Loading branch information...
1 parent ed74638 commit 2d4072892423d58cb0eda7f9d4db8ccf2b1faefd @dregad dregad committed Mar 24, 2014
Showing with 87 additions and 4 deletions.
  1. +50 −1 tests/bootstrap.php.sample
  2. +37 −3 tests/soap/SoapBase.php
@@ -1,4 +1,53 @@
<?php
+# MantisBT phpUnit tests sample bootstrap file
+
+/**
+ * Mantis Webservice Tests
+ *
+ * @package Tests
+ * @subpackage UnitTests
+ * @copyright Copyright (C) 2010-2013 MantisBT Team - mantisbt-dev@lists.sourceforge.net
+ * @link http://www.mantisbt.org
+ */
+
+/**
+ * Enable the test suite
+ * @global bool $GLOBALS['MANTIS_TESTSUITE_SOAP_ENABLED']
+ * @name MANTIS_TESTSUITE_SOAP_ENABLED
+ */
$GLOBALS['MANTIS_TESTSUITE_SOAP_ENABLED'] = true;
+
+/**
+ * URL for SOAP API wsdl file
+ * @global string $GLOBALS['MANTIS_TESTSUITE_SOAP_HOST']
+ * @name MANTIS_TESTSUITE_SOAP_HOST
+ */
$GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'] = 'http://localhost/mantisbt/api/soap/mantisconnect.php?wsdl';
-?>
+
+/**
+ * The user account that will run the tests
+ * @global string $GLOBALS['MANTIS_TESTSUITE_USERNAME']
+ * @name MANTIS_TESTSUITE_USERNAME
+ */
+$GLOBALS['MANTIS_TESTSUITE_USERNAME'] = 'administrator';
+
+/**
+ * The user's Password
+ * @global string $GLOBALS['MANTIS_TESTSUITE_PASSWORD']
+ * @name MANTIS_TESTSUITE_PASSWORD
+ */
+$GLOBALS['MANTIS_TESTSUITE_PASSWORD'] = 'root';
+
+/**
+ * The user's email address
+ * @global string $GLOBALS['MANTIS_TESTSUITE_EMAIL']
+ * @name MANTIS_TESTSUITE_EMAIL
+ */
+$GLOBALS['MANTIS_TESTSUITE_EMAIL'] = 'root@localhost';
+
+/**
+ * Project ID
+ * @global int $GLOBALS['MANTIS_TESTSUITE_PROJECT_ID']
+ * @name MANTIS_TESTSUITE_PROJECT_ID
+ */
+$GLOBALS['MANTIS_TESTSUITE_PROJECT_ID'] = 1;
@@ -67,6 +67,11 @@ class SoapBase extends PHPUnit_Framework_TestCase {
protected $mantisPath;
/**
+ * Project ID
+ */
+ protected $projectId = 1;
+
+ /**
* Array of Issue IDs to delete
*/
private $issueIdsToDelete = array();
@@ -100,13 +105,42 @@ protected function setUp()
$this->markTestSkipped( 'The Soap tests are disabled.' );
}
+ $this->assertTrue(
+ array_key_exists('MANTIS_TESTSUITE_SOAP_HOST', $GLOBALS) &&
+ !empty($GLOBALS['MANTIS_TESTSUITE_SOAP_HOST']),
+ "You must define 'MANTIS_TESTSUITE_SOAP_HOST' in your bootstrap file"
+ );
$this->client = new SoapClient(
$GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'],
array_merge($this->defaultSoapClientOptions, $this->extraSoapClientFlags()
)
);
$this->mantisPath = substr($GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'], 0, -strlen('api/soap/mantisconnect.php?wsdl'));
+
+ if (array_key_exists('MANTIS_TESTSUITE_USERNAME', $GLOBALS)) {
+ $this->userName = $GLOBALS['MANTIS_TESTSUITE_USERNAME'];
+ } else {
+ $this->userName = 'administrator';
+ }
+
+ if (array_key_exists('MANTIS_TESTSUITE_PASSWORD', $GLOBALS)) {
+ $this->password = $GLOBALS['MANTIS_TESTSUITE_PASSWORD'];
+ } else {
+ $this->password = 'root';
+ }
+
+ if (array_key_exists('MANTIS_TESTSUITE_EMAIL', $GLOBALS)) {
+ $this->email = $GLOBALS['MANTIS_TESTSUITE_EMAIL'];
+ } else {
+ $this->email = 'root@localhost';
+ }
+
+ if (array_key_exists('MANTIS_TESTSUITE_PROJECT_ID', $GLOBALS)) {
+ $this->projectId = $GLOBALS['MANTIS_TESTSUITE_PROJECT_ID'];
+ } else {
+ $this->projectId = 1;
+ }
}
/**
@@ -141,9 +175,9 @@ protected function tearDown() {
/**
* return default project id
*/
- protected function getProjectId() {
- return 1;
- }
+ protected function getProjectId() {
+ return $this->projectId;
+ }
/**
* return default category

0 comments on commit 2d40728

Please sign in to comment.