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