makasim/sfPhpunitPlugin — Issue #15: Add some helper methods in sfBasePhpunitAmfTestCase
Author: stephanebachelier
Created: 2012-01-12 13:32:41+00:00
State: open

Hi.

I've added some method to this class. I don't know if you are ok with these methods. I was tired of repeating myself. I have thought before to create a subclass of sfBasePhpunitAmfTestCase but maybe it's better to add them to your class.

I think these methods are explicit but I can send you an example, and a pull request.

diff --git a/plugins/sfPhpunitPlugin/lib/testcase/sfBasePhpunitAmfTestCase.class.php b/plugins/sfPhpunitPlugin/lib/testcase/sfBasePhpunitAmfTestCase.class.php
--- a/plugins/sfPhpunitPlugin/lib/testcase/sfBasePhpunitAmfTestCase.class.php
+++ b/plugins/sfPhpunitPlugin/lib/testcase/sfBasePhpunitAmfTestCase.class.php
@@ -132,4 +132,36 @@

return new sfPhpunitAmfService($this->_amfservice, $client);
}
+
+ protected $_amfVoPackage = false;
+ protected $_amfVoClassname = false;
+
+ protected function getVOClassname()
+ {
+ if ((false == $this->_amfPackage) || (false == $this->_amfVO))
+ {
+ throw new Exception('Value object package and/or classname not set');
+ }
+ return sprint('%s.%s', $this->_amfPackage, $this->_amfVO);
+ }
+
+ protected function doTestArrayResponse($response = null)
+ {
+ $this->assertNotNull($response, 'Response should not be null');
+
+ $this->assertInternalType(PHPUnit_Framework_Constraint_IsType::TYPE_ARRAY, $response);
+ $this->assertNotEmpty($response);
+
+ $this->doTestSingleVoReponse($response[0]);
+
+ return $response;
+ }
+
+ public function doTestSingleVoReponse($vo = null)
+ {
+ $this->assertNotNull($vo->getAMFData(), 'Value object should not be null');
+ $this->assertEquals($this->getVOClassname(), $vo->getAMFClassname(), 'Value object is not the correct classname');
+
+ return $vo;
+ }
}
\ No newline at end of file