1
0

WebfingerTest.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. namespace Tests\Unit;
  3. use Tests\TestCase;
  4. use App\Util\Lexer\Nickname;
  5. class WebfingerTest extends TestCase
  6. {
  7. /** @test */
  8. public function webfingerTest()
  9. {
  10. $expected = [
  11. "domain" => "pixelfed.org",
  12. "username" => "dansup",
  13. ];
  14. $actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
  15. $this->assertEquals($expected, $actual);
  16. $expected = [
  17. "domain" => "pixelfed.org",
  18. "username" => "dansup_",
  19. ];
  20. $actual = Nickname::normalizeProfileUrl('acct:dansup@pixelfed.org');
  21. $this->assertNotEquals($expected, $actual);
  22. $expected = [
  23. "domain" => "pixelfed.org",
  24. "username" => "dansup",
  25. ];
  26. $actual = Nickname::normalizeProfileUrl('acct:@dansup@pixelfed.org');
  27. $this->assertEquals($expected, $actual);
  28. $expected = [
  29. "domain" => "pixelfed.org",
  30. "username" => "dansup",
  31. ];
  32. $actual = Nickname::normalizeProfileUrl('dansup@pixelfed.org');
  33. $this->assertEquals($expected, $actual);
  34. $expected = [
  35. "domain" => "pixelfed.org",
  36. "username" => "dansup",
  37. ];
  38. $actual = Nickname::normalizeProfileUrl('@dansup@pixelfed.org');
  39. $this->assertEquals($expected, $actual);
  40. }
  41. }