DocsTest.php 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_Docs
  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 'Zend/Gdata/Docs.php';
  23. require_once 'Zend/Gdata/HttpClient.php';
  24. require_once 'Zend/Gdata/TestUtility/MockHttpClient.php';
  25. /**
  26. * @category Zend
  27. * @package Zend_Gdata_Docs
  28. * @subpackage UnitTests
  29. * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
  30. * @license http://framework.zend.com/license/new-bsd New BSD License
  31. * @group Zend_Gdata
  32. * @group Zend_Gdata_Docs
  33. */
  34. class Zend_Gdata_DocsTest extends PHPUnit_Framework_TestCase
  35. {
  36. public function setUp()
  37. {
  38. $this->adapter = new Test_Zend_Gdata_MockHttpClient();
  39. $this->client = new Zend_Gdata_HttpClient();
  40. $this->client->setAdapter($this->adapter);
  41. $this->gdata = new Zend_Gdata_Docs($this->client);
  42. }
  43. public function testCreateFolder()
  44. {
  45. $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n'));
  46. $this->gdata->createFolder("Test Folder");
  47. $request = $this->adapter->popRequest();
  48. // Check to make sure the correct URI is in use
  49. $this->assertEquals(
  50. "docs.google.com",
  51. $request->uri->getHost());
  52. $this->assertEquals(
  53. "/feeds/documents/private/full",
  54. $request->uri->getPath());
  55. // Check to make sure that this is a folder
  56. $this->assertNotEquals( false, strpos($request->body,
  57. "<atom:category term=\"http://schemas.google.com/docs/2007#folder\" scheme=\"http://schemas.google.com/g/2005#kind\""));
  58. // Check to make sure the title is set
  59. $this->assertNotEquals(false, strpos($request->body,
  60. "<atom:title type=\"text\">Test Folder</atom:title>"));
  61. }
  62. public function testCreateSubfolder()
  63. {
  64. $subfolderName = "MySubfolder";
  65. $this->adapter->setResponse(array('HTTP/1.1 200 OK\r\n\r\n'));
  66. $this->gdata->createFolder("Test Folder", $subfolderName);
  67. $request = $this->adapter->popRequest();
  68. // Check to make sure the correct URI is in use
  69. $this->assertEquals(
  70. "docs.google.com",
  71. $request->uri->getHost());
  72. $this->assertEquals(
  73. "/feeds/folders/private/full/" . $subfolderName,
  74. $request->uri->getPath());
  75. // Check to make sure that this is a folder
  76. $this->assertNotEquals( false, strpos($request->body,
  77. "<atom:category term=\"http://schemas.google.com/docs/2007#folder\" scheme=\"http://schemas.google.com/g/2005#kind\""));
  78. // Check to make sure the title is set
  79. $this->assertNotEquals(false, strpos($request->body,
  80. "<atom:title type=\"text\">Test Folder</atom:title>"));
  81. }
  82. }