From 208d3023d4acc775275b89c96a66293c242a735d Mon Sep 17 00:00:00 2001 From: Robert Munteanu Date: Sun, 16 May 2010 11:36:37 +0300 Subject: [PATCH] Verify that the SOAP API works properly when compression is requested. --- tests/soap/AllTests.php | 2 ++ tests/soap/CompressionTest.php | 62 ++++++++++++++++++++++++++++++++++ tests/soap/SoapBase.php | 11 ++++-- 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 tests/soap/CompressionTest.php diff --git a/tests/soap/AllTests.php b/tests/soap/AllTests.php index c307e79b77..d5e94c7b72 100644 --- a/tests/soap/AllTests.php +++ b/tests/soap/AllTests.php @@ -34,6 +34,7 @@ require_once 'AttachmentTest.php'; require_once 'LoginTest.php'; require_once 'CategoryTest.php'; +require_once 'CompressionTest.php'; /** * @package Tests @@ -65,6 +66,7 @@ public static function suite() $suite->addTestSuite('AttachmentTest'); $suite->addTestSuite('LoginTest'); $suite->addTestSuite('CategoryTest'); + $suite->addTestSuite('CompressionTest'); return $suite; } diff --git a/tests/soap/CompressionTest.php b/tests/soap/CompressionTest.php new file mode 100644 index 0000000000..6bdaf6fcea --- /dev/null +++ b/tests/soap/CompressionTest.php @@ -0,0 +1,62 @@ +. + +/** + * @package Tests + * @subpackage UnitTests + * @copyright Copyright (C) 2010 MantisBT Team - mantisbt-dev@lists.sourceforge.net + * @link http://www.mantisbt.org + */ + +require_once 'SoapBase.php'; + +/** + * Test fixture for calls with compression enabled + */ +class CompressionTest extends SoapBase { + + /** + * A test case that tests the following: + * + *
    + *
  1. Creating an issue.
  2. + *
  3. Retrieving an issue.
  4. + *
+ * + *

If any of the calls performed with compression enabled will + * fail, the test will fail in turn with a SoapFault.

+ */ + public function testGetIssueWithCompressionEnabled() { + $issueToAdd = $this->getIssueToAdd( 'CompressionTest.testUpdateSummary' ); + + $issueId = $this->client->mc_issue_add( + $this->userName, + $this->password, + $issueToAdd); + + $this->deleteAfterRun( $issueId ); + + $createdIssue = $this->client->mc_issue_get( + $this->userName, + $this->password, + $issueId); + } + + protected function extraSoapClientFlags() { + + return array('compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP); + } +} diff --git a/tests/soap/SoapBase.php b/tests/soap/SoapBase.php index a941c54fde..e90bb260a4 100644 --- a/tests/soap/SoapBase.php +++ b/tests/soap/SoapBase.php @@ -46,11 +46,12 @@ protected function setUp() !$GLOBALS['MANTIS_TESTSUITE_SOAP_ENABLED']) { $this->markTestSkipped( 'The Soap tests are disabled.' ); } - + $this->client = new SoapClient( $GLOBALS['MANTIS_TESTSUITE_SOAP_HOST'], - array_merge($this->defaultSoapClientOptions, $this->extraSoapClientFlags()) + array_merge($this->defaultSoapClientOptions, $this->extraSoapClientFlags() + ) ); } @@ -120,4 +121,10 @@ protected function skipIfAllowNoCategoryIsDisabled() { $this->markTestSkipped( 'g_allow_no_category is not ON.' ); } } + + protected function skipIsZlibIsNotAvailable() { + if( !extension_loaded( 'zlib' ) ) { + $this->markTestSkipped('zlib extension not found.'); + } + } }