2
0

GappsTest.php 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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. * @category Zend
  16. * @package Zend_Gdata
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2006 Zend Technologies USA Inc. (http://www.zend.com)
  19. * @license http://framework.zend.com/license/new-bsd New BSD License
  20. */
  21. require_once 'TestHelper.php';
  22. require_once 'Zend/Gdata/Gapps.php';
  23. require_once 'Zend/Gdata/ClientLogin.php';
  24. require_once 'Zend/Http/Client.php';
  25. /**
  26. * @package Zend_Gdata
  27. * @subpackage UnitTests
  28. */
  29. class Zend_Gdata_GappsTest extends PHPUnit_Framework_TestCase
  30. {
  31. const TEST_DOMAIN = 'nowhere.invalid';
  32. public function setUp()
  33. {
  34. // These tests shouldn't be doing anything online, so we can use
  35. // bogous auth credentials.
  36. $this->gdata = new Zend_Gdata_Gapps(null, self::TEST_DOMAIN);
  37. }
  38. public function testMagicFactoryProvidesQueriesWithDomains() {
  39. $userQ = $this->gdata->newUserQuery();
  40. $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery);
  41. $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain());
  42. $this->assertEquals(null, $userQ->getUsername());
  43. $userQ = $this->gdata->newUserQuery('foo');
  44. $this->assertTrue($userQ instanceof Zend_Gdata_Gapps_UserQuery);
  45. $this->assertEquals(self::TEST_DOMAIN, $userQ->getDomain());
  46. $this->assertEquals('foo', $userQ->getUsername());
  47. }
  48. public function testMagicFactoryLeavesNonQueriesAlone() {
  49. $login = $this->gdata->newLogin('blah');
  50. $this->assertTrue($login instanceof Zend_Gdata_Gapps_Extension_Login);
  51. $this->assertEquals('blah', $login->username);
  52. }
  53. public function testEmptyResponseExceptionRaisesException() {
  54. require_once('Zend/Gdata/App/HttpException.php');
  55. $e = new Zend_Gdata_App_HttpException();
  56. $e->setResponse(null);
  57. $success = false;
  58. try {
  59. $this->gdata->throwServiceExceptionIfDetected($e);
  60. } catch (Zend_Gdata_App_IOException $f) {
  61. $success = true;
  62. }
  63. $this->assertTrue($success, 'Zend_Gdata_App_IOException not thrown');
  64. }
  65. }