EmbedTest.php 3.3 KB

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