AcceptVerbTest.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. namespace Tests\Unit\ActivityPub\Verb;
  3. use Tests\TestCase;
  4. use Illuminate\Foundation\Testing\WithFaker;
  5. use Illuminate\Foundation\Testing\RefreshDatabase;
  6. use App\Util\ActivityPub\Validator\Accept;
  7. class AcceptVerbTest extends TestCase
  8. {
  9. protected $validAccept;
  10. protected $invalidAccept;
  11. public function setUp(): void
  12. {
  13. parent::setUp();
  14. $this->validAccept = [
  15. '@context' => 'https://www.w3.org/ns/activitystreams',
  16. 'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
  17. 'type' => 'Accept',
  18. 'actor' => 'https://example.org/u/alice',
  19. 'object' => [
  20. 'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
  21. 'type' => 'Follow',
  22. 'actor' => 'https://example.net/u/bob',
  23. 'object' => 'https://example.org/u/alice'
  24. ]
  25. ];
  26. $this->invalidAccept = [
  27. '@context' => 'https://www.w3.org/ns/activitystreams',
  28. 'id' => 'https://example.org/og/b3e4a40b-0b26-4c5a-9079-094bd633fab7',
  29. 'type' => 'Accept2',
  30. 'actor' => 'https://example.org/u/alice',
  31. 'object' => [
  32. 'id' => 'https://example.net/u/bob#follows/bb27f601-ddb9-4567-8f16-023d90605ca9',
  33. 'type' => 'Follow',
  34. 'actor' => 'https://example.net/u/bob',
  35. 'object' => 'https://example.org/u/alice'
  36. ]
  37. ];
  38. }
  39. /** @test */
  40. public function basic_accept()
  41. {
  42. $this->assertTrue(Accept::validate($this->validAccept));
  43. }
  44. /** @test */
  45. public function invalid_accept()
  46. {
  47. $this->assertFalse(Accept::validate($this->invalidAccept));
  48. }
  49. }