HttpExceptionTest.php 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. <?php
  2. /**
  3. * Zend Framework
  4. *
  5. * LICENSE
  6. *
  7. * This source file is subject to the new BSD license that is bundled
  8. * with this package in the file LICENSE.txt.
  9. * It is also available through the world-wide-web at this URL:
  10. * http://framework.zend.com/license/new-bsd
  11. * If you did not receive a copy of the license and are unable to
  12. * obtain it through the world-wide-web, please send an email
  13. * to license@zend.com so we can send you a copy immediately.
  14. *
  15. * @package Zend_Gdata_App
  16. * @subpackage UnitTests
  17. * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com);
  18. * @license http://framework.zend.com/license/new-bsd New BSD License
  19. */
  20. require_once dirname(dirname(dirname(dirname(__FILE__)))) . DIRECTORY_SEPARATOR . 'TestHelper.php';
  21. require_once 'Zend/Gdata/App.php';
  22. require_once 'Zend/Gdata/Spreadsheets.php';
  23. require_once 'Zend/Http/Client.php';
  24. require_once 'Zend/Gdata/ClientLogin.php';
  25. /**
  26. * @package Zend_Gdata_App
  27. * @subpackage UnitTests
  28. */
  29. class Zend_Gdata_App_HttpExceptionTest extends PHPUnit_Framework_TestCase
  30. {
  31. public function setUp()
  32. {
  33. $user = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_EMAIL');
  34. $pass = constant('TESTS_ZEND_GDATA_CLIENTLOGIN_PASSWORD');
  35. $this->sprKey = constant('TESTS_ZEND_GDATA_SPREADSHEETS_SPREADSHEETKEY');
  36. $this->wksId = constant('TESTS_ZEND_GDATA_SPREADSHEETS_WORKSHEETID');
  37. $service = Zend_Gdata_Spreadsheets::AUTH_SERVICE_NAME;
  38. $client = Zend_Gdata_ClientLogin::getHttpClient($user, $pass, $service);
  39. $this->gdata = new Zend_Gdata_Spreadsheets($client);
  40. }
  41. public function testGetRawResponseBody()
  42. {
  43. try {
  44. $rowData = array();
  45. $entry = $this->gdata->insertRow($rowData, $this->sprKey);
  46. $this->fail('Expecting Zend_Gdata_App_HttpException');
  47. } catch (Zend_Gdata_App_HttpException $hExc) {
  48. $this->assertThat($hExc,
  49. $this->isInstanceOf('Zend_Gdata_App_HttpException'),
  50. 'Expecting Zend_Gdata_App_HttpException, got '
  51. . get_class($hExc));
  52. $message = $hExc->getMessage();
  53. $this->assertEquals($message, 'Expected response code 200, got 400');
  54. $body = $hExc->getRawResponseBody();
  55. $this->assertNotNull($body);
  56. $this->assertNotEquals(stripos($body,
  57. 'Blank rows cannot be written; use delete instead.'), false);
  58. }
  59. }
  60. }