TagURITest.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. // This file is part of GNU social - https://www.gnu.org/software/social
  3. //
  4. // GNU social is free software: you can redistribute it and/or modify
  5. // it under the terms of the GNU Affero General Public License as published by
  6. // the Free Software Foundation, either version 3 of the License, or
  7. // (at your option) any later version.
  8. //
  9. // GNU social is distributed in the hope that it will be useful,
  10. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. // GNU Affero General Public License for more details.
  13. //
  14. // You should have received a copy of the GNU Affero General Public License
  15. // along with GNU social. If not, see <http://www.gnu.org/licenses/>.
  16. namespace Tests\Unit;
  17. if (!defined('INSTALLDIR')) {
  18. define('INSTALLDIR', dirname(dirname(__DIR__)));
  19. }
  20. if (!defined('PUBLICDIR')) {
  21. define('PUBLICDIR', INSTALLDIR . DIRECTORY_SEPARATOR . 'public');
  22. }
  23. if (!defined('GNUSOCIAL')) {
  24. define('GNUSOCIAL', true);
  25. }
  26. if (!defined('STATUSNET')) { // Compatibility
  27. define('STATUSNET', true);
  28. }
  29. use PHPUnit\Framework\TestCase;
  30. require_once INSTALLDIR . '/lib/util/common.php';
  31. $config['site']['server'] = 'example.net';
  32. $config['site']['path'] = '/apps/statusnet';
  33. final class TagURITest extends TestCase
  34. {
  35. /**
  36. * @dataProvider provider
  37. *
  38. * @param $format
  39. * @param $args
  40. * @param $uri
  41. */
  42. public function testProduction($format, $args, $uri)
  43. {
  44. $minted = call_user_func_array(
  45. ['TagURI', 'mint'],
  46. array_merge([$format], $args)
  47. );
  48. static::assertSame($uri, $minted);
  49. }
  50. public static function provider()
  51. {
  52. return [['favorite:%d:%d',
  53. [1, 3],
  54. 'tag:example.net,' . date('Y-m-d') . ':apps:statusnet:favorite:1:3',]];
  55. }
  56. }