EmbedTest.php 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <?php
  2. // {{{ License
  3. // This file is part of GNU social - https://www.gnu.org/software/social
  4. //
  5. // GNU social is free software: you can redistribute it and/or modify
  6. // it under the terms of the GNU Affero General Public License as published by
  7. // the Free Software Foundation, either version 3 of the License, or
  8. // (at your option) any later version.
  9. //
  10. // GNU social is distributed in the hope that it will be useful,
  11. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. // GNU Affero General Public License for more details.
  14. //
  15. // You should have received a copy of the GNU Affero General Public License
  16. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  17. // }}}
  18. /**
  19. * OembedPlugin implementation for GNU social
  20. *
  21. * @package GNUsocial
  22. *
  23. * @author Mikael Nordfeldth
  24. * @author Diogo Cordeiro <diogo@fc.up.pt>
  25. * @copyright 2019 Free Software Foundation, Inc http://www.fsf.org
  26. * @license https://www.gnu.org/licenses/agpl.html GNU AGPL v3 or later
  27. */
  28. namespace Plugin\Embed\Test;
  29. use PHPUnit\Framework\TestCase;
  30. final class EmbedTest extends TestCase
  31. {
  32. /**
  33. * Run tests
  34. *
  35. * @param string $url
  36. * @param string $expectedType
  37. * @dataProvider sources
  38. */
  39. public function testEmbed($url, $expectedType)
  40. {
  41. // try {
  42. // $data = EmbedHelper::getObject($url);
  43. // static::assertSame($expectedType, $data->type);
  44. // if ($data->type == 'photo') {
  45. // static::assertTrue(!empty($data->thumbnail_url), 'Photo must have a URL.');
  46. // static::assertTrue(!empty($data->thumbnail_width), 'Photo must have a width.');
  47. // static::assertTrue(!empty($data->thumbnail_height), 'Photo must have a height.');
  48. // } elseif ($data->type == 'video') {
  49. // static::assertTrue(!empty($data->html), 'Video must have embedding HTML.');
  50. // static::assertTrue(!empty($data->thumbnail_url), 'Video should have a thumbnail.');
  51. // } else {
  52. // static::assertTrue(!empty($data->title), 'Page must have a title');
  53. // static::assertTrue(!empty($data->url), 'Page must have a URL');
  54. // }
  55. // if (!empty($data->thumbnail_url)) {
  56. // static::assertTrue(!empty($data->thumbnail_width), 'Thumbnail must list a width.');
  57. // static::assertTrue(!empty($data->thumbnail_height), 'Thumbnail must list a height.');
  58. // }
  59. // } catch (Exception $e) {
  60. // if ($expectedType == 'none') {
  61. // static::assertSame($expectedType, 'none', 'Should not have data for this URL.');
  62. // } else {
  63. // throw $e;
  64. // }
  65. // }
  66. }
  67. public static function sources()
  68. {
  69. return [
  70. ['https://notabug.org/', 'link'],
  71. ['http://www.youtube.com/watch?v=eUgLR232Cnw', 'video'],
  72. [GNUSOCIAL_ENGINE_URL, 'link'],
  73. ['https://www.gnu.org/graphics/heckert_gnu.transp.small.png', 'photo'],
  74. ['http://vimeo.com/9283184', 'video'],
  75. ['http://leuksman.com/log/2010/10/29/statusnet-0-9-6-release/', 'none'],
  76. ['https://github.com/git/git/commit/85e9c7e1d42849c5c3084a9da748608468310c0e', 'link'],
  77. ];
  78. }
  79. }