WebfingerTest.php 1.4 KB

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