kopia lustrzana https://github.com/pixelfed/pixelfed
Merge pull request #5908 from helmet91/clean-up-test-deprecations
[Improvement] Clean up test deprecationspull/5925/head
commit
cc6f0debc2
|
@ -10,6 +10,8 @@
|
|||
/.gitconfig
|
||||
#/.gitignore
|
||||
/.idea
|
||||
/.phpunit.cache
|
||||
/.phpunit.result.cache
|
||||
/.vagrant
|
||||
/bootstrap/cache
|
||||
/docker-compose-state/
|
||||
|
|
24
phpunit.xml
24
phpunit.xml
|
@ -1,20 +1,18 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="false"
|
||||
backupStaticAttributes="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
convertErrorsToExceptions="true"
|
||||
convertNoticesToExceptions="true"
|
||||
convertWarningsToExceptions="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd">
|
||||
<coverage processUncoveredFiles="true">
|
||||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
backupGlobals="false"
|
||||
backupStaticProperties="false"
|
||||
bootstrap="vendor/autoload.php"
|
||||
colors="true"
|
||||
processIsolation="false"
|
||||
stopOnFailure="false"
|
||||
cacheDirectory=".phpunit.cache"
|
||||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.5/phpunit.xsd">
|
||||
<source>
|
||||
<include>
|
||||
<directory suffix=".php">./app</directory>
|
||||
</include>
|
||||
</coverage>
|
||||
</source>
|
||||
<testsuites>
|
||||
<testsuite name="Feature">
|
||||
<directory suffix="Test.php">./tests/Feature</directory>
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LoginTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function view_login_page()
|
||||
{
|
||||
$response = $this->get('login');
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class APAnnounceStrategyTest extends TestCase
|
||||
|
@ -26,22 +27,26 @@ class APAnnounceStrategyTest extends TestCase
|
|||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
|
||||
public function testBasicValidation()
|
||||
#[Test]
|
||||
public function basicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
|
||||
public function testMastodonValidation()
|
||||
#[Test]
|
||||
public function mastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
|
||||
public function testPleromaValidation()
|
||||
#[Test]
|
||||
public function pleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
|
||||
public function testMastodonAudienceScope()
|
||||
#[Test]
|
||||
public function mastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
|
@ -56,7 +61,8 @@ class APAnnounceStrategyTest extends TestCase
|
|||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testPleromaAudienceScope()
|
||||
#[Test]
|
||||
public function pleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
|
@ -71,7 +77,8 @@ class APAnnounceStrategyTest extends TestCase
|
|||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
#[Test]
|
||||
public function invalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AudienceScopeTest extends TestCase
|
||||
|
@ -28,22 +29,26 @@ class AudienceScopeTest extends TestCase
|
|||
$this->pleroma = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","actor":"https://pleroma.site/users/pixeldev","cc":["https://www.w3.org/ns/activitystreams#Public"],"context":"tag:mastodon.social,2018-10-14:objectId=59146153:objectType=Conversation","context_id":12325955,"id":"https://pleroma.site/activities/db2273eb-d504-4e3a-8f74-c343d069755a","object":"https://mastodon.social/users/dansup/statuses/100891324792793720","published":"2018-10-14T01:22:18.554227Z","to":["https://pleroma.site/users/pixeldev/followers","https://mastodon.social/users/dansup"],"type":"Announce"}', true);
|
||||
}
|
||||
|
||||
public function testBasicValidation()
|
||||
#[Test]
|
||||
public function basicValidation()
|
||||
{
|
||||
$this->assertFalse(Helpers::validateObject($this->invalid));
|
||||
}
|
||||
|
||||
public function testMastodonValidation()
|
||||
#[Test]
|
||||
public function mastodonValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->mastodon));
|
||||
}
|
||||
|
||||
public function testPleromaValidation()
|
||||
#[Test]
|
||||
public function pleromaValidation()
|
||||
{
|
||||
$this->assertTrue(Helpers::validateObject($this->pleroma));
|
||||
}
|
||||
|
||||
public function testMastodonAudienceScope()
|
||||
#[Test]
|
||||
public function mastodonAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->mastodon, false);
|
||||
$actual = [
|
||||
|
@ -58,7 +63,8 @@ class AudienceScopeTest extends TestCase
|
|||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testPleromaAudienceScope()
|
||||
#[Test]
|
||||
public function pleromaAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->pleroma, false);
|
||||
$actual = [
|
||||
|
@ -73,7 +79,8 @@ class AudienceScopeTest extends TestCase
|
|||
$this->assertEquals($scope, $actual);
|
||||
}
|
||||
|
||||
public function testInvalidAudienceScope()
|
||||
#[Test]
|
||||
public function invalidAudienceScope()
|
||||
{
|
||||
$scope = Helpers::normalizeAudience($this->invalid, false);
|
||||
$actual = [
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class NoteAttachmentTest extends TestCase
|
||||
|
@ -28,25 +29,29 @@ class NoteAttachmentTest extends TestCase
|
|||
$this->invalidMime = json_decode('{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791/activity","type":"Create","actor":"https://mastodon.social/users/dansup","published":"2018-10-13T18:43:33Z","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"object":{"id":"https://mastodon.social/users/dansup/statuses/100889802384218791","type":"Note","summary":null,"inReplyTo":null,"published":"2018-10-13T18:43:33Z","url":"https://mastodon.social/@dansup/100889802384218791","attributedTo":"https://mastodon.social/users/dansup","to":["https://www.w3.org/ns/activitystreams#Public"],"cc":["https://mastodon.social/users/dansup/followers"],"sensitive":false,"atomUri":"https://mastodon.social/users/dansup/statuses/100889802384218791","inReplyToAtomUri":null,"conversation":"tag:mastodon.social,2018-10-13:objectId=59103420:objectType=Conversation","content":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>","contentMap":{"en":"<p>Good Morning! <a href=\"https://mastodon.social/tags/coffee\" class=\"mention hashtag\" rel=\"tag\">#<span>coffee</span></a></p>"},"attachment":[{"type":"Document","mediaType":"image/webp","url":"https://files.mastodon.social/media_attachments/files/007/110/573/original/96a196885a77c9a4.jpg","name":null}],"tag":[{"type":"Hashtag","href":"https://mastodon.social/tags/coffee","name":"#coffee"}]}}', true, 9);
|
||||
}
|
||||
|
||||
public function testPixelfed()
|
||||
#[Test]
|
||||
public function pixelfed()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->pixelfed);
|
||||
$this->assertTrue($valid);
|
||||
}
|
||||
|
||||
public function testMastodon()
|
||||
#[Test]
|
||||
public function mastodon()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->mastodon);
|
||||
$this->assertTrue($valid);
|
||||
}
|
||||
|
||||
public function testInvalidAttachmentType()
|
||||
#[Test]
|
||||
public function invalidAttachmentType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidType);
|
||||
$this->assertFalse($valid);
|
||||
}
|
||||
|
||||
public function testInvalidMimeType()
|
||||
#[Test]
|
||||
public function invalidMimeType()
|
||||
{
|
||||
$valid = Helpers::verifyAttachments($this->invalidMime);
|
||||
$this->assertFalse($valid);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use App\Util\ActivityPub\Helpers;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RemoteFollowTest extends TestCase
|
||||
|
@ -17,7 +18,7 @@ class RemoteFollowTest extends TestCase
|
|||
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function validateMastodonFollowObject()
|
||||
{
|
||||
$mastodon = json_decode($this->mastodon, true);
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use App\Util\ActivityPub\Validator\StoryValidator;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class StoryValidationTest extends TestCase
|
||||
|
@ -16,13 +17,13 @@ class StoryValidationTest extends TestCase
|
|||
$this->activity = json_decode('{"@context":"https://www.w3.org/ns/activitystreams","id":"https://pixelfed.test/stories/dansup/338581222496276480","type":"Story","to":["https://pixelfed.test/users/dansup/followers"],"cc":[],"attributedTo":"https://pixelfed.test/users/dansup","published":"2021-09-01T07:20:53+00:00","expiresAt":"2021-09-02T07:21:04+00:00","duration":3,"can_reply":true,"can_react":true,"attachment":{"type":"Image","url":"https://pixelfed.test/storage/_esm.t3/xV9/R2LF1xwhAA/011oqKVPDySG3WCPW7yIs2wobvccoITMnG/yT_FZX04f2DCzTA3K8HD2OS7FptXTHPiE1c_ZkHASBQ8UlPKH4.jpg","mediaType":"image/jpeg"}}', true);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function schemaTest()
|
||||
{
|
||||
$this->assertTrue(StoryValidator::validate($this->activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -31,7 +32,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -39,7 +40,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -47,7 +48,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -55,7 +56,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -63,7 +64,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingTo()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -71,7 +72,7 @@ class StoryValidationTest extends TestCase
|
|||
$this->assertFalse(StoryValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingTimestamps()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub;
|
||||
|
||||
use App\Util\ActivityPub\Validator\UpdatePersonValidator;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class UpdatePersonValidationTest extends TestCase
|
||||
|
@ -16,13 +17,13 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->activity = json_decode('{"type":"Update","object":{"url":"http://mastodon.example.org/@gargron","type":"Person","summary":"<p>Some bio</p>","publicKey":{"publicKeyPem":"-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA0gs3VnQf6am3R+CeBV4H\nlfI1HZTNRIBHgvFszRZkCERbRgEWMu+P+I6/7GJC5H5jhVQ60z4MmXcyHOGmYMK/\n5XyuHQz7V2Ssu1AxLfRN5Biq1ayb0+DT/E7QxNXDJPqSTnstZ6C7zKH/uAETqg3l\nBonjCQWyds+IYbQYxf5Sp3yhvQ80lMwHML3DaNCMlXWLoOnrOX5/yK5+dedesg2\n/HIvGk+HEt36vm6hoH7bwPuEkgA++ACqwjXRe5Mta7i3eilHxFaF8XIrJFARV0t\nqOu4GID/jG6oA+swIWndGrtR2QRJIt9QIBFfK3HG5M0koZbY1eTqwNFRHFL3xaD\nUQIDAQAB\n-----END PUBLIC KEY-----\n","owner":"http://mastodon.example.org/users/gargron","id":"http://mastodon.example.org/users/gargron#main-key"},"preferredUsername":"gargron","outbox":"http://mastodon.example.org/users/gargron/outbox","name":"gargle","manuallyApprovesFollowers":false,"inbox":"http://mastodon.example.org/users/gargron/inbox","id":"http://mastodon.example.org/users/gargron","following":"http://mastodon.example.org/users/gargron/following","followers":"http://mastodon.example.org/users/gargron/followers","endpoints":{"sharedInbox":"http://mastodon.example.org/inbox"},"attachment":[{"type":"PropertyValue","name":"foo","value":"updated"},{"type":"PropertyValue","name":"foo1","value":"updated"}],"icon":{"type":"Image","mediaType":"image/jpeg","url":"https://cd.niu.moe/accounts/avatars/000/033/323/original/fd7f8ae0b3ffedc9.jpeg"},"image":{"type":"Image","mediaType":"image/png","url":"https://cd.niu.moe/accounts/headers/000/033/323/original/850b3448fa5fd477.png"}},"id":"http://mastodon.example.org/users/gargron#updates/1519563538","actor":"http://mastodon.example.org/users/gargron","@context":["https://www.w3.org/ns/activitystreams","https://w3id.org/security/v1",{"toot":"http://joinmastodon.org/ns#","sensitive":"as:sensitive","ostatus":"http://ostatus.org#","movedTo":"as:movedTo","manuallyApprovesFollowers":"as:manuallyApprovesFollowers","inReplyToAtomUri":"ostatus:inReplyToAtomUri","conversation":"ostatus:conversation","atomUri":"ostatus:atomUri","Hashtag":"as:Hashtag","Emoji":"toot:Emoji"}]}', true);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function schemaTest()
|
||||
{
|
||||
$this->assertTrue(UpdatePersonValidator::validate($this->activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -31,7 +32,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingContext()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -39,7 +40,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -47,7 +48,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -55,7 +56,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -63,7 +64,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidObjectType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -71,7 +72,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorMatchingObjectId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -79,7 +80,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorUrlMatchingObjectId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -87,7 +88,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingActorPublicKey()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -95,7 +96,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorPublicKey()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -103,7 +104,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorPublicKeyId()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -111,7 +112,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorPublicKeyIdHost()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -119,7 +120,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorAvatar()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -127,7 +128,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidActorAvatarMediaType()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -135,7 +136,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertFalse(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function validActorAvatarMediaTypePng()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -143,7 +144,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertTrue(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function validActorAvatarMediaTypeJpeg()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
@ -151,7 +152,7 @@ class UpdatePersonValidationTest extends TestCase
|
|||
$this->assertTrue(UpdatePersonValidator::validate($activity));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function validActorAvatarMediaUrl()
|
||||
{
|
||||
$activity = $this->activity;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub\Verb;
|
||||
|
||||
use App\Util\ActivityPub\Validator\Accept;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AcceptVerbTest extends TestCase
|
||||
|
@ -77,19 +78,19 @@ class AcceptVerbTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->validAccept));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Accept::validate($this->invalidAccept));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mastodon_accept()
|
||||
{
|
||||
$this->assertTrue(Accept::validate($this->mastodonAccept));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub\Verb;
|
||||
|
||||
use App\Util\ActivityPub\Validator\Announce;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AnnounceTest extends TestCase
|
||||
|
@ -138,32 +139,32 @@ class AnnounceTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function basic_accept()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->validAnnounce));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalid_accept()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidAnnounce));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function context_missing()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->contextMissing));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalid_actor()
|
||||
{
|
||||
$this->assertFalse(Announce::validate($this->invalidActor));
|
||||
$this->assertFalse(Announce::validate($this->invalidActor2));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function mastodon_announce()
|
||||
{
|
||||
$this->assertTrue(Announce::validate($this->mastodonAnnounce));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub\Verb;
|
||||
|
||||
use App\Util\ActivityPub\Validator\Follow;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class FollowTest extends TestCase
|
||||
|
@ -44,7 +45,7 @@ class FollowTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function basic_follow()
|
||||
{
|
||||
$this->assertTrue(Follow::validate($this->basicFollow));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub\Verb;
|
||||
|
||||
use App\Util\ActivityPub\Validator\Like;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class LikeTest extends TestCase
|
||||
|
@ -44,7 +45,7 @@ class LikeTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function basic_like()
|
||||
{
|
||||
$this->assertTrue(Like::validate($this->basicLike));
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit\ActivityPub\Verb;
|
||||
|
||||
use App\Util\ActivityPub\Validator\UndoFollow;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UndoFollowTest extends TestCase
|
||||
|
@ -28,13 +29,13 @@ class UndoFollowTest extends TestCase
|
|||
];
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function valid_undo_follow()
|
||||
{
|
||||
$this->assertTrue(UndoFollow::validate($this->validUndo));
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalid_undo_follow()
|
||||
{
|
||||
$this->assertFalse(UndoFollow::validate($this->invalidUndo));
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class ActivityPubTagObjectTest extends TestCase
|
||||
|
@ -9,7 +10,8 @@ class ActivityPubTagObjectTest extends TestCase
|
|||
/**
|
||||
* A basic unit test example.
|
||||
*/
|
||||
public function test_gotosocial(): void
|
||||
#[Test]
|
||||
public function gotosocial(): void
|
||||
{
|
||||
$res = [
|
||||
"tag" => [
|
||||
|
@ -33,7 +35,8 @@ class ActivityPubTagObjectTest extends TestCase
|
|||
$this->assertTrue($tags->count() === 1);
|
||||
}
|
||||
|
||||
public function test_pixelfed_hashtags(): void
|
||||
#[Test]
|
||||
public function pixelfed_hashtags(): void
|
||||
{
|
||||
$res = [
|
||||
"tag" => [
|
||||
|
@ -94,8 +97,8 @@ class ActivityPubTagObjectTest extends TestCase
|
|||
$this->assertTrue($tags->count() === 7);
|
||||
}
|
||||
|
||||
|
||||
public function test_pixelfed_mentions(): void
|
||||
#[Test]
|
||||
public function pixelfed_mentions(): void
|
||||
{
|
||||
$res = [
|
||||
"tag" => [
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use App\Util\Lexer\Bearcap;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
class BearcapTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function validTest()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -19,7 +20,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidTokenParameterName()
|
||||
{
|
||||
$str = 'bear:?token=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -27,7 +28,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidUrlParameterName()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -35,7 +36,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidScheme()
|
||||
{
|
||||
$str = 'bearcap:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&url=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -43,7 +44,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingToken()
|
||||
{
|
||||
$str = 'bear:?u=https://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -51,7 +52,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function missingUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2';
|
||||
|
@ -59,7 +60,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidHttpUrl()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=http://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
@ -67,7 +68,7 @@ class BearcapTest extends TestCase
|
|||
$this->assertFalse($actual);
|
||||
}
|
||||
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function invalidUrlSchema()
|
||||
{
|
||||
$str = 'bear:?t=LpVypnEUdHhwwgXE9tTqEwrtPvmLjqYaPexqyXnVo1flSfJy5AYMCdRPiFRmqld2&u=phar://pixelfed.test/stories/admin/337892163734081536';
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use phpseclib\Crypt\RSA;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class CryptoTest extends TestCase
|
||||
|
@ -12,12 +13,14 @@ class CryptoTest extends TestCase
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testLibraryInstalled()
|
||||
#[Test]
|
||||
public function libraryInstalled()
|
||||
{
|
||||
$this->assertTrue(class_exists('\phpseclib\Crypt\RSA'));
|
||||
}
|
||||
|
||||
public function testRSASigning()
|
||||
#[Test]
|
||||
public function RSASigning()
|
||||
{
|
||||
$rsa = new RSA();
|
||||
extract($rsa->createKey());
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
namespace Tests\Unit\Lexer;
|
||||
|
||||
use App\Util\Lexer\RestrictedNames;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class RestrictedNameTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function restrictedUsername()
|
||||
{
|
||||
$names = RestrictedNames::get();
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Tests\Unit\Lexer;
|
|||
use App\Status;
|
||||
use App\Util\Lexer\Autolink;
|
||||
use App\Util\Lexer\Extractor;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StatusLexerTest extends TestCase
|
||||
|
@ -21,7 +22,8 @@ class StatusLexerTest extends TestCase
|
|||
$this->autolink = Autolink::create()->autolink($this->status);
|
||||
}
|
||||
|
||||
public function testLexerExtractor()
|
||||
#[Test]
|
||||
public function lexerExtractor()
|
||||
{
|
||||
$expected = [
|
||||
'hashtags' => [
|
||||
|
@ -56,13 +58,14 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals($this->entities, $expected);
|
||||
}
|
||||
|
||||
public function testAutolink()
|
||||
#[Test]
|
||||
public function autolink()
|
||||
{
|
||||
$expected = '<a class="u-url mention" href="https://pixelfed.dev/pixelfed" rel="external nofollow noopener" target="_blank">@pixelfed</a> hi, really like the website! <a href="https://pixelfed.dev/discover/tags/píxelfed?src=hash" title="#píxelfed" class="u-url hashtag" rel="external nofollow noopener">#píxelfed</a>';
|
||||
$this->assertEquals($this->autolink, $expected);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function remoteMention()
|
||||
{
|
||||
$expected = [
|
||||
|
@ -106,7 +109,7 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals($actual, $expected);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function mentionLimit()
|
||||
{
|
||||
$text = '@test1 @test @test2 @test3 @test4 @test5 @test6 @test7 @test8 @test9 @test10 @test11 @test12 @test13 @test14 @test15 @test16 @test17 @test18 @test19 test post';
|
||||
|
@ -116,7 +119,7 @@ class StatusLexerTest extends TestCase
|
|||
$this->assertEquals(Status::MAX_MENTIONS, $count);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function hashtagLimit()
|
||||
{
|
||||
$text = '#hashtag0 #hashtag1 #hashtag2 #hashtag3 #hashtag4 #hashtag5 #hashtag6 #hashtag7 #hashtag8 #hashtag9 #hashtag10 #hashtag11 #hashtag12 #hashtag13 #hashtag14 #hashtag15 #hashtag16 #hashtag17 #hashtag18 #hashtag19 #hashtag20 #hashtag21 #hashtag22 #hashtag23 #hashtag24 #hashtag25 #hashtag26 #hashtag27 #hashtag28 #hashtag29 #hashtag30 #hashtag31 #hashtag0 #hashtag1 #hashtag2 #hashtag3 #hashtag4 #hashtag5 #hashtag6 #hashtag7 #hashtag8 #hashtag9 #hashtag10 #hashtag11 #hashtag12 #hashtag13 #hashtag14 #hashtag15 #hashtag16 #hashtag17 #hashtag18 #hashtag19 #hashtag20 #hashtag21 #hashtag22 #hashtag23 #hashtag24 #hashtag25 #hashtag26 #hashtag27 #hashtag28 #hashtag29 #hashtag30 #hashtag31';
|
||||
|
@ -127,7 +130,7 @@ class StatusLexerTest extends TestCase
|
|||
}
|
||||
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function linkLimit()
|
||||
{
|
||||
$text = 'https://example.org https://example.net https://example.com https://example.com https://example.net';
|
||||
|
|
|
@ -4,11 +4,12 @@ namespace Tests\Unit\Lexer;
|
|||
|
||||
use App\Util\Lexer\Autolink;
|
||||
use App\Util\Lexer\Extractor;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class UsernameTest extends TestCase
|
||||
{
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function genericUsername()
|
||||
{
|
||||
$username = '@dansup';
|
||||
|
@ -38,7 +39,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function usernameWithPeriod()
|
||||
{
|
||||
$username = '@dansup.two';
|
||||
|
@ -68,7 +69,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function usernameWithDash()
|
||||
{
|
||||
$username = '@dansup-too';
|
||||
|
@ -98,7 +99,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function usernameWithUnderscore()
|
||||
{
|
||||
$username = '@dansup_too';
|
||||
|
@ -128,7 +129,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function multipleMentions()
|
||||
{
|
||||
$text = 'hello @dansup and @pixelfed.team from @username_underscore';
|
||||
|
@ -175,7 +176,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function germanUmlatsAutolink()
|
||||
{
|
||||
$mentions = "@März and @königin and @Glück";
|
||||
|
@ -185,7 +186,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedAutolink, $autolink);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function germanUmlatsExtractor()
|
||||
{
|
||||
$mentions = "@März and @königin and @Glück";
|
||||
|
@ -229,7 +230,7 @@ class UsernameTest extends TestCase
|
|||
$this->assertEquals($expectedEntity, $entities);
|
||||
}
|
||||
|
||||
/** @test * */
|
||||
#[Test]
|
||||
public function germanUmlatsWebfingerAutolink()
|
||||
{
|
||||
$mentions = "hello @märz@example.org!";
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
|
||||
namespace Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Purify;
|
||||
use Tests\TestCase;
|
||||
|
||||
class PurifierTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function puckTest()
|
||||
{
|
||||
$actual = Purify::clean("<span class=\"fa-spin fa\">catgirl spinning around in the interblag</span>");
|
||||
|
|
|
@ -3,11 +3,12 @@
|
|||
namespace Tests\Unit;
|
||||
|
||||
use App\Util\Lexer\Nickname;
|
||||
use PHPUnit\Framework\Attributes\Test;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebfingerTest extends TestCase
|
||||
{
|
||||
/** @test */
|
||||
#[Test]
|
||||
public function webfingerTest()
|
||||
{
|
||||
$expected = [
|
||||
|
|
Ładowanie…
Reference in New Issue