PageRenderTime 37ms CodeModel.GetById 16ms RepoModel.GetById 0ms app.codeStats 0ms

/ZendFramework/tests/Zend/Gdata/Photos/PhotosAlbumEntryTest.php

https://bitbucket.org/Dal-Papa/is-340-publish-base
PHP | 364 lines | 179 code | 44 blank | 141 comment | 0 complexity | 4e38e038fceef36f839d0e9f99fd4cfb MD5 | raw file
  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_Photos
  17. * @subpackage UnitTests
  18. * @copyright Copyright (c) 2005-2012 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/Photos.php';
  23. require_once 'Zend/Gdata/Photos/AlbumEntry.php';
  24. require_once 'Zend/Http/Client.php';
  25. require_once 'Zend/Http/Client/Adapter/Test.php';
  26. /**
  27. * @category Zend
  28. * @package Zend_Gdata_Photos
  29. * @subpackage UnitTests
  30. * @copyright Copyright (c) 2005-2012 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_Photos
  34. */
  35. class Zend_Gdata_Photos_PhotosAlbumEntryTest extends PHPUnit_Framework_TestCase
  36. {
  37. protected $albumEntry = null;
  38. /**
  39. * Called before each test to setup any fixtures.
  40. */
  41. public function setUp()
  42. {
  43. $albumEntryText = file_get_contents(
  44. '_files/TestAlbumEntry.xml',
  45. true);
  46. $this->albumEntry = new Zend_Gdata_Photos_AlbumEntry($albumEntryText);
  47. }
  48. /**
  49. * Verify that a given property is set to a specific value
  50. * and that the getter and magic variable return the same value.
  51. *
  52. * @param object $obj The object to be interrogated.
  53. * @param string $name The name of the property to be verified.
  54. * @param object $value The expected value of the property.
  55. */
  56. protected function verifyProperty($obj, $name, $value)
  57. {
  58. $propName = $name;
  59. $propGetter = "get" . ucfirst($name);
  60. $this->assertEquals($obj->$propGetter(), $obj->$propName);
  61. $this->assertEquals($value, $obj->$propGetter());
  62. }
  63. /**
  64. * Verify that a given property is set to a specific value
  65. * and that the getter and magic variable return the same value.
  66. *
  67. * @param object $obj The object to be interrogated.
  68. * @param string $name The name of the property to be verified.
  69. * @param string $secondName 2nd level accessor function name
  70. * @param object $value The expected value of the property.
  71. */
  72. protected function verifyProperty2($obj, $name, $secondName, $value)
  73. {
  74. $propName = $name;
  75. $propGetter = "get" . ucfirst($name);
  76. $secondGetter = "get" . ucfirst($secondName);
  77. $this->assertEquals($obj->$propGetter(), $obj->$propName);
  78. $this->assertEquals($value, $obj->$propGetter()->$secondGetter());
  79. }
  80. /**
  81. * Verify that a given property is set to a specific value,
  82. * that it keeps that value when set using the setter,
  83. * and that the getter and magic variable return the same value.
  84. *
  85. * @param object $obj The object to be interrogated.
  86. * @param string $name The name of the property to be verified.
  87. * @param string $secondName 2nd level accessor function name
  88. * @param object $value The expected value of the property.
  89. */
  90. protected function verifyProperty3($obj, $name, $secondName, $value)
  91. {
  92. $propName = $name;
  93. $propGetter = "get" . ucfirst($name);
  94. $propSetter = "set" . ucfirst($name);
  95. $secondGetter = "get" . ucfirst($secondName);
  96. $secondSetter = "set" . ucfirst($secondName);
  97. $this->assertEquals($obj->$propGetter(), $obj->$propName);
  98. $obj->$propSetter($obj->$propName);
  99. $this->assertEquals($value, $obj->$propGetter()->$secondGetter());
  100. }
  101. /**
  102. * Check for the existence of an <atom:author> and verify that they
  103. * contain the expected values.
  104. */
  105. public function testAuthor()
  106. {
  107. $entry = $this->albumEntry;
  108. // Assert that the entry's author is correct
  109. $entryAuthor = $entry->getAuthor();
  110. $this->assertEquals($entryAuthor, $entry->author);
  111. $this->assertEquals(1, count($entryAuthor));
  112. $this->assertTrue($entryAuthor[0] instanceof Zend_Gdata_App_Extension_Author);
  113. $this->verifyProperty2($entryAuthor[0], "name", "text", "sample");
  114. $this->assertTrue($entryAuthor[0]->getUri() instanceof Zend_Gdata_App_Extension_Uri);
  115. $this->verifyProperty2($entryAuthor[0], "uri", "text", "http://picasaweb.google.com/sample.user");
  116. }
  117. /**
  118. * Check for the existence of an <atom:id> and verify that it contains
  119. * the expected value.
  120. */
  121. public function testId()
  122. {
  123. $entry = $this->albumEntry;
  124. // Assert that the entry's ID is correct
  125. $this->assertTrue($entry->getId() instanceof Zend_Gdata_App_Extension_Id);
  126. $this->verifyProperty2($entry, "id", "text",
  127. "http://picasaweb.google.com/data/entry/api/user/sample.user/albumid/1");
  128. }
  129. /**
  130. * Check for the existence of an <atom:published> and verify that it contains
  131. * the expected value.
  132. */
  133. public function testPublished()
  134. {
  135. $entry = $this->albumEntry;
  136. // Assert that the photo entry has an Atom Published object
  137. $this->assertTrue($entry->getPublished() instanceof Zend_Gdata_App_Extension_Published);
  138. $this->verifyProperty2($entry, "published", "text", "2007-09-05T07:00:00.000Z");
  139. }
  140. /**
  141. * Check for the existence of an <atom:updated> and verify that it contains
  142. * the expected value.
  143. */
  144. public function testUpdated()
  145. {
  146. $entry = $this->albumEntry;
  147. // Assert that the entry's updated date is correct
  148. $this->assertTrue($entry->getUpdated() instanceof Zend_Gdata_App_Extension_Updated);
  149. $this->verifyProperty2($entry, "updated", "text",
  150. "2007-09-05T20:49:24.000Z");
  151. }
  152. /**
  153. * Check for the existence of an <atom:title> and verify that it contains
  154. * the expected value.
  155. */
  156. public function testTitle()
  157. {
  158. $entry = $this->albumEntry;
  159. // Assert that the entry's title is correct
  160. $this->assertTrue($entry->getTitle() instanceof Zend_Gdata_App_Extension_Title);
  161. $this->verifyProperty2($entry, "title", "text", "Test");
  162. }
  163. /**
  164. * Check for the existence of an <gphoto:user> and verify that it contains
  165. * the expected value.
  166. */
  167. public function testGphotoUser()
  168. {
  169. $entry = $this->albumEntry;
  170. // Assert that the entry's title is correct
  171. $this->assertTrue($entry->getGphotoUser() instanceof Zend_Gdata_Photos_Extension_User);
  172. $this->verifyProperty2($entry, "gphotoUser", "text",
  173. "sample.user");
  174. $this->verifyProperty3($entry, "gphotoUser", "text",
  175. "sample.user");
  176. }
  177. /**
  178. * Check for the existence of an <gphoto:nickname> and verify that it contains
  179. * the expected value.
  180. */
  181. public function testGphotoNickname()
  182. {
  183. $entry = $this->albumEntry;
  184. // Assert that the entry's title is correct
  185. $this->assertTrue($entry->getGphotoNickname() instanceof Zend_Gdata_Photos_Extension_Nickname);
  186. $this->verifyProperty2($entry, "gphotoNickname", "text",
  187. "sample");
  188. $this->verifyProperty3($entry, "gphotoNickname", "text",
  189. "sample");
  190. }
  191. /**
  192. * Check for the existence of an <gphoto:name> and verify that it contains
  193. * the expected value.
  194. */
  195. public function testGphotoName()
  196. {
  197. $entry = $this->albumEntry;
  198. // Assert that the entry's title is correct
  199. $this->assertTrue($entry->getGphotoName() instanceof Zend_Gdata_Photos_Extension_Name);
  200. $this->verifyProperty2($entry, "gphotoName", "text",
  201. "Test");
  202. $this->verifyProperty3($entry, "gphotoName", "text",
  203. "Test");
  204. }
  205. /**
  206. * Check for the existence of an <gphoto:id> and verify that it contains
  207. * the expected value.
  208. */
  209. public function testGphotoId()
  210. {
  211. $entry = $this->albumEntry;
  212. // Assert that the entry's title is correct
  213. $this->assertTrue($entry->getGphotoId() instanceof Zend_Gdata_Photos_Extension_Id);
  214. $this->verifyProperty2($entry, "gphotoId", "text",
  215. "1");
  216. $this->verifyProperty3($entry, "gphotoId", "text",
  217. "1");
  218. }
  219. /**
  220. * Check for the existence of an <gphoto:location> and verify that it contains
  221. * the expected value.
  222. */
  223. public function testGphotoLocation()
  224. {
  225. $entry = $this->albumEntry;
  226. // Assert that the entry's title is correct
  227. $this->assertTrue($entry->getGphotoLocation() instanceof Zend_Gdata_Photos_Extension_Location);
  228. $this->verifyProperty2($entry, "gphotoLocation", "text",
  229. "");
  230. }
  231. /**
  232. * Check for the existence of an <gphoto:access> and verify that it contains
  233. * the expected value.
  234. */
  235. public function testGphotoAccess()
  236. {
  237. $entry = $this->albumEntry;
  238. // Assert that the entry's title is correct
  239. $this->assertTrue($entry->getGphotoAccess() instanceof Zend_Gdata_Photos_Extension_Access);
  240. $this->verifyProperty2($entry, "gphotoAccess", "text",
  241. "public");
  242. $this->verifyProperty3($entry, "gphotoAccess", "text",
  243. "public");
  244. }
  245. /**
  246. * Check for the existence of an <gphoto:timestamp> and verify that it contains
  247. * the expected value.
  248. */
  249. public function testGphotoTimestamp()
  250. {
  251. $entry = $this->albumEntry;
  252. // Assert that the entry's title is correct
  253. $this->assertTrue($entry->getGphotoTimestamp() instanceof Zend_Gdata_Photos_Extension_Timestamp);
  254. $this->verifyProperty2($entry, "gphotoTimestamp", "text",
  255. "1188975600000");
  256. $this->verifyProperty3($entry, "gphotoTimestamp", "text",
  257. "1188975600000");
  258. }
  259. /**
  260. * Check for the existence of an <gphoto:numphotos> and verify that it contains
  261. * the expected value.
  262. */
  263. public function testGphotoNumPhotos()
  264. {
  265. $entry = $this->albumEntry;
  266. // Assert that the entry's title is correct
  267. $this->assertTrue($entry->getGphotoNumPhotos() instanceof Zend_Gdata_Photos_Extension_NumPhotos);
  268. $this->verifyProperty2($entry, "gphotoNumPhotos", "text",
  269. "2");
  270. $this->verifyProperty3($entry, "gphotoNumPhotos", "text",
  271. "2");
  272. }
  273. /**
  274. * Check for the existence of an <gphoto:commentingEnabled> and verify that it contains
  275. * the expected value.
  276. */
  277. public function testGphotoCommentingEnabled()
  278. {
  279. $entry = $this->albumEntry;
  280. // Assert that the entry's title is correct
  281. $this->assertTrue($entry->getGphotoCommentingEnabled() instanceof Zend_Gdata_Photos_Extension_CommentingEnabled);
  282. $this->verifyProperty2($entry, "gphotoCommentingEnabled", "text",
  283. "true");
  284. $this->verifyProperty3($entry, "gphotoCommentingEnabled", "text",
  285. "true");
  286. }
  287. /**
  288. * Check for the existence of an <gphoto:commentCount> and verify that it contains
  289. * the expected value.
  290. */
  291. public function testGphotoCommentCount()
  292. {
  293. $entry = $this->albumEntry;
  294. // Assert that the entry's title is correct
  295. $this->assertTrue($entry->getGphotoCommentCount() instanceof Zend_Gdata_Photos_Extension_CommentCount);
  296. $this->verifyProperty2($entry, "gphotoCommentCount", "text",
  297. "0");
  298. $this->verifyProperty3($entry, "gphotoCommentCount", "text",
  299. "0");
  300. }
  301. /**
  302. * Check for the existence of a <media:group>
  303. */
  304. public function testMediaGroup()
  305. {
  306. $entry = $this->albumEntry;
  307. // Assert that the entry's media group exists
  308. $this->assertTrue($entry->getMediaGroup() instanceof Zend_Gdata_Media_Extension_MediaGroup);
  309. }
  310. /**
  311. * Check for the geo data and verify that it contains the expected values
  312. */
  313. public function testGeoData()
  314. {
  315. $geoRssWhere = $this->albumEntry->geoRssWhere;
  316. $point = $geoRssWhere->point;
  317. $pos = $point->pos;
  318. $this->assertEquals("42.87194 13.56738", $pos->text);
  319. }
  320. }