PageRenderTime 25ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 1ms

/test/unit/org/tubepress/options/reference/OptionsReferenceTest.php

http://tubepress.googlecode.com/
PHP | 246 lines | 232 code | 14 blank | 0 comment | 10 complexity | c510e0cb41ebd1f16cd88ef17f8eaba9 MD5 | raw file
Possible License(s): GPL-3.0, CC-BY-SA-4.0, BSD-3-Clause
  1. <?php
  2. require_once dirname(__FILE__) . '/../../../../../../classes/org/tubepress/options/reference/OptionsReference.class.php';
  3. require_once dirname(__FILE__) . '/../../../../../../classes/org/tubepress/options/Category.class.php';
  4. require_once dirname(__FILE__) . '/../../../../../../test/unit/TubePressUnitTest.php';
  5. class org_tubepress_options_reference_OptionsReferenceTest extends TubePressUnitTest {
  6. private $_options = array(
  7. org_tubepress_options_Type::COLOR => array(
  8. org_tubepress_options_category_Embedded::PLAYER_COLOR => '999999',
  9. org_tubepress_options_category_Embedded::PLAYER_HIGHLIGHT => 'FFFFFF'
  10. ),
  11. org_tubepress_options_Type::MODE => array(
  12. org_tubepress_options_category_Gallery::MODE => 'recently_featured'
  13. ),
  14. org_tubepress_options_Type::TEXT => array(
  15. org_tubepress_options_category_Advanced::DATEFORMAT => 'M j, Y',
  16. org_tubepress_options_category_Advanced::KEYWORD => 'tubepress',
  17. org_tubepress_options_category_Advanced::VIDEO_BLACKLIST => '',
  18. org_tubepress_options_category_Gallery::FAVORITES_VALUE => 'mrdeathgod',
  19. org_tubepress_options_category_Gallery::PLAYLIST_VALUE => 'D2B04665B213AE35',
  20. org_tubepress_options_category_Gallery::TAG_VALUE => 'stewart daily show',
  21. org_tubepress_options_category_Gallery::USER_VALUE => '3hough',
  22. org_tubepress_options_category_Feed::DEV_KEY => 'AI39si5uUzupiQW9bpzGqZRrhvqF3vBgRqL-I_28G1zWozmdNJlskzMDQEhpZ-l2RqGf_6CNWooL96oJZRrqKo-eJ9QO_QppMg',
  23. org_tubepress_options_category_Widget::TITLE => 'TubePress',
  24. org_tubepress_options_category_Widget::TAGSTRING => '[tubepress thumbHeight=\'105\' thumbWidth=\'135\']',
  25. org_tubepress_options_category_Gallery::VIDEO => '',
  26. org_tubepress_options_category_Gallery::VIMEO_UPLOADEDBY_VALUE => 'mattkaar',
  27. org_tubepress_options_category_Gallery::VIMEO_LIKES_VALUE => 'coiffier',
  28. org_tubepress_options_category_Gallery::VIMEO_APPEARS_IN_VALUE => 'royksopp',
  29. org_tubepress_options_category_Gallery::VIMEO_SEARCH_VALUE => 'cats playing piano',
  30. org_tubepress_options_category_Gallery::VIMEO_CREDITED_VALUE => 'patricklawler',
  31. org_tubepress_options_category_Gallery::VIMEO_CHANNEL_VALUE => 'splitscreenstuff',
  32. org_tubepress_options_category_Gallery::VIMEO_GROUP_VALUE => 'hdxs',
  33. org_tubepress_options_category_Gallery::VIMEO_ALBUM_VALUE => '140484',
  34. org_tubepress_options_category_Gallery::DIRECTORY_VALUE => 'sample_videos',
  35. org_tubepress_options_category_Uploads::FFMPEG_BINARY_LOCATION => '',
  36. org_tubepress_options_category_Uploads::ADMIN_PAGE_PASSWORD => ''
  37. ),
  38. org_tubepress_options_Type::BOOL => array(
  39. org_tubepress_options_category_Advanced::DEBUG_ON => true,
  40. org_tubepress_options_category_Display::RANDOM_THUMBS => true,
  41. org_tubepress_options_category_Display::RELATIVE_DATES => false,
  42. org_tubepress_options_category_Display::PAGINATE_ABOVE => true,
  43. org_tubepress_options_category_Display::PAGINATE_BELOW => true,
  44. org_tubepress_options_category_Display::AJAX_PAGINATION => false,
  45. org_tubepress_options_category_Display::HQ_THUMBS => false,
  46. org_tubepress_options_category_Embedded::AUTOPLAY => false,
  47. org_tubepress_options_category_Embedded::BORDER => false,
  48. org_tubepress_options_category_Embedded::GENIE => false,
  49. org_tubepress_options_category_Embedded::LOOP => false,
  50. org_tubepress_options_category_Embedded::SHOW_INFO => false,
  51. org_tubepress_options_category_Embedded::SHOW_RELATED => true,
  52. org_tubepress_options_category_Embedded::FULLSCREEN => true,
  53. org_tubepress_options_category_Embedded::HIGH_QUALITY => false,
  54. org_tubepress_options_category_Meta::AUTHOR => false,
  55. org_tubepress_options_category_Meta::CATEGORY => false,
  56. org_tubepress_options_category_Meta::DESCRIPTION => false,
  57. org_tubepress_options_category_Meta::ID => false,
  58. org_tubepress_options_category_Meta::LENGTH => true,
  59. org_tubepress_options_category_Meta::RATING => false,
  60. org_tubepress_options_category_Meta::RATINGS => false,
  61. org_tubepress_options_category_Meta::TAGS => false,
  62. org_tubepress_options_category_Meta::TITLE => true,
  63. org_tubepress_options_category_Meta::UPLOADED => false,
  64. org_tubepress_options_category_Meta::URL => false,
  65. org_tubepress_options_category_Meta::VIEWS => true,
  66. org_tubepress_options_category_Meta::LIKES => false,
  67. org_tubepress_options_category_Feed::CACHE_ENABLED => false,
  68. org_tubepress_options_category_Feed::EMBEDDABLE_ONLY => true
  69. ),
  70. org_tubepress_options_Type::INTEGRAL => array(
  71. org_tubepress_options_category_Display::DESC_LIMIT => 80,
  72. org_tubepress_options_category_Display::RESULTS_PER_PAGE => 20,
  73. org_tubepress_options_category_Display::THUMB_HEIGHT => 90,
  74. org_tubepress_options_category_Display::THUMB_WIDTH => 120,
  75. org_tubepress_options_category_Embedded::EMBEDDED_HEIGHT => 350,
  76. org_tubepress_options_category_Embedded::EMBEDDED_WIDTH => 425,
  77. org_tubepress_options_category_Feed::RESULT_COUNT_CAP => 300,
  78. org_tubepress_options_category_Uploads::THUMBS_PER_VIDEO => 3,
  79. ),
  80. org_tubepress_options_Type::TIME_FRAME => array(
  81. org_tubepress_options_category_Gallery::MOST_VIEWED_VALUE => 'today',
  82. org_tubepress_options_category_Gallery::TOP_RATED_VALUE => 'today'
  83. ),
  84. org_tubepress_options_Type::ORDER => array(
  85. org_tubepress_options_category_Display::ORDER_BY => 'viewCount',
  86. ),
  87. org_tubepress_options_Type::PLAYER => array(
  88. org_tubepress_options_category_Display::CURRENT_PLAYER_NAME => 'normal',
  89. ),
  90. org_tubepress_options_Type::SAFE_SEARCH => array(
  91. org_tubepress_options_category_Feed::FILTER => 'moderate'
  92. ),
  93. org_tubepress_options_Type::PLAYER_IMPL => array(
  94. org_tubepress_options_category_Embedded::PLAYER_IMPL => 'youtube'
  95. ),
  96. org_tubepress_options_Type::THEME => array(
  97. org_tubepress_options_category_Display::THEME => ''
  98. )
  99. );
  100. function testGetAdvancedOptionNames()
  101. {
  102. $expectedNames = array(
  103. 'dateFormat', 'debugging_enabled', 'keyword',
  104. 'videoBlacklist'
  105. );
  106. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::ADVANCED));
  107. }
  108. function testGetAllOptionNames()
  109. {
  110. $expected = array();
  111. foreach ($this->_options as $optionType) {
  112. $expected = array_merge($expected, array_keys($optionType));
  113. }
  114. $this->assertTrue($expected == org_tubepress_options_reference_OptionsReference::getAllOptionNames());
  115. }
  116. function testGetDefaultValue()
  117. {
  118. foreach ($this->_options as $optionType) {
  119. foreach ($optionType as $optionName => $defaultValue) {
  120. $this->assertEquals($defaultValue, org_tubepress_options_reference_OptionsReference::getDefaultValue($optionName));
  121. }
  122. }
  123. }
  124. function testGetDisplayOptionNames()
  125. {
  126. $expectedNames = array('theme', 'ajaxPagination', 'playerLocation', 'resultsPerPage', 'hqThumbs', 'thumbHeight', 'thumbWidth',
  127. 'orderBy', 'paginationAbove', 'paginationBelow', 'randomize_thumbnails', 'relativeDates' ,'descriptionLimit'
  128. );
  129. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::DISPLAY));
  130. }
  131. function testGetEmbeddedOptionNames()
  132. {
  133. $expectedNames = array(
  134. 'playerImplementation', 'embeddedHeight', 'embeddedWidth',
  135. 'autoplay', 'border', 'fullscreen', 'hd', 'genie', 'loop', 'playerColor',
  136. 'playerHighlight', 'showInfo', 'showRelated'
  137. );
  138. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::EMBEDDED));
  139. }
  140. function testGetFeedOptionNames()
  141. {
  142. $expectedNames = array(
  143. 'cacheEnabled', 'embeddableOnly', 'filter_racy', 'developerKey', 'resultCountCap'
  144. );
  145. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::FEED));
  146. }
  147. function testGetGalleryOptionNames()
  148. {
  149. $expectedNames = array(
  150. 'mode', 'video', 'directoryValue', 'favoritesValue', 'most_viewedValue', 'playlistValue',
  151. 'tagValue', 'top_ratedValue', 'userValue', 'vimeoUploadedByValue','vimeoLikesValue',
  152. 'vimeoAppearsInValue', 'vimeoSearchValue', 'vimeoCreditedToValue', 'vimeoChannelValue',
  153. 'vimeoAlbumValue', 'vimeoGroupValue'
  154. );
  155. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::GALLERY));
  156. }
  157. function testGetMetaOptionNames()
  158. {
  159. $expectedNames = array(
  160. 'author', 'category', 'description', 'id',
  161. 'length', 'likes', 'rating', 'ratings', 'tags',
  162. 'title', 'uploaded', 'url', 'views'
  163. );
  164. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::META));
  165. }
  166. function testIsOptionName()
  167. {
  168. $expected = array();
  169. foreach ($this->_options as $optionType) {
  170. foreach($optionType as $optionName => $value) {
  171. $this->assertTrue(org_tubepress_options_reference_OptionsReference::isOptionName($optionName));
  172. }
  173. }
  174. $this->assertFalse(org_tubepress_options_reference_OptionsReference::isOptionName('obviously fake option name'));
  175. }
  176. function testGetWidgetOptionNames()
  177. {
  178. $expectedNames = array(
  179. 'widget-tagstring', 'widget-title'
  180. );
  181. $this->assertTrue($expectedNames == org_tubepress_options_reference_OptionsReference::getOptionNamesForCategory(org_tubepress_options_Category::WIDGET));
  182. }
  183. function testGetType()
  184. {
  185. $types = array_keys($this->_options);
  186. for ($x = 0; $x < sizeof($types); $x++) {
  187. foreach ($this->_options[$types[$x]] as $optionName => $value) {
  188. $this->assertEquals($types[$x], org_tubepress_options_reference_OptionsReference::getType($optionName));
  189. }
  190. }
  191. }
  192. function testGetOptionCategoryNames()
  193. {
  194. $expected = array('gallery', 'display', 'embedded', 'meta', 'feed', 'uploads', 'advanced', 'widget');
  195. $this->assertTrue($expected == org_tubepress_options_reference_OptionsReference::getOptionCategoryNames());
  196. }
  197. function testGetCategory()
  198. {
  199. $categories = array('gallery', 'display', 'embedded', 'feed', 'meta', 'widget');
  200. foreach ($categories as $category) {
  201. $classname = 'org_tubepress_options_category_' . ucwords($category);
  202. $ref = new ReflectionClass($classname);
  203. foreach ($ref->getConstants() as $constant) {
  204. $this->assertEquals($category, org_tubepress_options_reference_OptionsReference::getCategory($constant));
  205. }
  206. }
  207. }
  208. function testPlayerEnumValues()
  209. {
  210. $expected = array('normal', 'popup','shadowbox', 'jqmodal', 'youtube', 'static', 'solo', 'vimeo');
  211. $this->assertEquals($expected, org_tubepress_options_reference_OptionsReference::getValidEnumValues(org_tubepress_options_Type::PLAYER));
  212. }
  213. function testMostViewedEnumValues()
  214. {
  215. $expected = array('today', 'this_week', 'this_month', 'all_time');
  216. $this->assertEquals($expected, org_tubepress_options_reference_OptionsReference::getValidEnumValues(org_tubepress_options_Type::TIME_FRAME));
  217. }
  218. function testOrderEnumValues()
  219. {
  220. $expected = array('relevance', 'viewCount', 'rating', 'published', 'random', 'position', 'commentCount', 'duration', 'title', 'newest', 'oldest');
  221. $this->assertEquals($expected, org_tubepress_options_reference_OptionsReference::getValidEnumValues(org_tubepress_options_Type::ORDER));
  222. }
  223. function testGalleryEnumValues()
  224. {
  225. $expected = array('directory', 'favorites', 'playlist', 'tag', 'user', 'recently_featured', 'mobile', 'most_discussed',
  226. 'most_linked', 'most_recent', 'most_responded', 'most_viewed',
  227. 'top_rated', 'vimeoUploadedBy', 'vimeoLikes', 'vimeoAppearsIn', 'vimeoSearch', 'vimeoCreditedTo',
  228. 'vimeoChannel', 'vimeoAlbum', 'vimeoGroup');
  229. $this->assertEquals($expected, org_tubepress_options_reference_OptionsReference::getValidEnumValues(org_tubepress_options_Type::MODE));
  230. }
  231. }
  232. ?>