I'm trying to use PHPUnit to test my Zend_Framework based SOAP server.
It's a simple application which has no controllers or views (too much
overhead), but it does use the Zend_Application and bootstrap model,
so I've been trying to use Zend_Test_PHPUnit_ControllerTestCase as it
is Zend_Application aware.
My application bootstrap looks like this: http://pastebin.com/m6971312e
My application index.php looks like this: http://pastebin.com/m3feae19a
then on the PHPUnit side of things I have a smaller Bootstrap:
http://pastebin.com/m7b61b419
and my test class http://pastebin.com/m40d5528c
Now my SOAP server works fine as a Zend_Application and I can view the
wsdl being generated and can test from a cli soap client but the Unit
Testing environment isn't getting set up correctly and when I run my
unit tests I'm getting SOAP errors, which are probably related to a
data backend problem which is due to the environment not being set up
the same way as the app Bootstrap. But it should be as far as I can
tell. All the code is the same between the unit test bootstrap and the
app bootstrap.
Any ideas?
tests looks like this at present
macdanosx:~/Sites/webservicewombat/tests dof$ phpunit SoapServerTest
PHPUnit 3.4.3 by Sebastian Bergmann.
PHP Warning: Cannot modify header information - headers already sent
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/
Soap/Server.php on line 829
PHP Warning: Cannot modify header information - headers already sent
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/
Soap/Server.php on line 829
PHP Warning: Cannot modify header information - headers already sent
by (output started at /usr/local/zend/share/pear/PHPUnit/Util/
Printer.php:173) in /usr/local/zend/share/ZendFramework/library/Zend/
Soap/Server.php on line 829
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/
"><SOAP-ENV:Body><SOAP-ENV:Fault><faultcode>Sender</
faultcode><faultstring>Invalid XML</faultstring></SOAP-ENV:Fault></
SOAP-ENV:Body></SOAP-ENV:Envelope>
if I comment the parent::setUp() line I get to the tests, albeit
failed tests (they probably should work!)
macdanosx:~/Sites/webservicewombat/tests dof$ phpunit SoapServerTest
PHPUnit 3.4.3 by Sebastian Bergmann.
.EE.EEE
Time: 0 seconds
There were 5 errors:
1) SoapServerTest::testGetProject
SoapFault: Unknown error
/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:44
2) SoapServerTest::testGetPhase
SoapFault: Unknown error
/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:49
3) SoapServerTest::testGetPageItem
SoapFault: Unknown error
/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:59
4) SoapServerTest::testPageItems
SoapFault: Call to a member function toArray() on a non-object
/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:64
5) SoapServerTest::testGetTaskStatus
SoapFault: Call to a member function toArray() on a non-object
/Users/dof/Sites/webservicewombat/tests/SoapServerTest.php:69
FAILURES!
Tests: 7, Assertions: 2, Errors: 5.
--
Dan Field <[email protected]> Ffôn/Tel. +44 1970 632 582
Peiriannydd Meddalwedd Senior Software Engineer
Llyfrgell Genedlaethol Cymru National Library of Wales