GappsTest.php 2.7 KB

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