<?php namespace ActivityPhpTest\Server; use ActivityPhp\Server; use ActivityPhp\Type; use PHPUnit\Framework\TestCase; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; class OutboxPostTest extends TestCase { /** * Valid scenarios provider */ public function getOutboxPostActivities() { return [ ["{\n "@context": ["https://www.w3.org/ns/activitystreams",\n {"@language": "en"}],\n "type": "Like",\n "actor": "https://dustycloud.org/chris/",\n "name": "Chris liked 'Minimal ActivityPhp update client'",\n "object": "https://rhiaro.co.uk/2016/05/minimal-activitypub",\n "to": ["https://rhiaro.co.uk/#amy",\n "https://dustycloud.org/followers",\n "https://rhiaro.co.uk/followers/"],\n "cc": "https://e14n.com/evan"\n}" ], # JSON formatted Like activity ["{\n "@context": "https://www.w3.org/ns/activitystreams",\n "type": "Note",\n "content": "This is a note",\n "published": "2015-02-10T15:04:55Z",\n "to": ["https://example.org/~john/"],\n "cc": ["https://example.com/~erik/followers",\n "https://www.w3.org/ns/activitystreams#Public"]\n}" ], # JSON formatted Note that should be wrapped into activity ["{\n "@context": "https://www.w3.org/ns/activitystreams",\n "type": "Note",\n "content": "This is a note",\n "published": "2015-02-10T15:04:55Z",\n "to": ["https://example.org/~john/"],\n "cc": ["https://example.com/~erik/followers",\n "https://www.w3.org/ns/activitystreams#Public"]\n}", 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"' ], # Accept headers should be accepted // --------------------------------------------------------------------- // Error scenarios // --------------------------------------------------------------------- ['bad JSON', 'application/activity+json', 400 ], # Bad JSON payload should return 400 Bad request ['bad JSON', 'text/html,application/xhtml+xml,application/xml', 400 ], # Accept header MUST be valid ]; } /** * Check that all response are valid * * @dataProvider getOutboxPostActivities */ public function testOutboxPostActivities($payload, $accept = 'application/activity+json', $code = 201) { $server = new Server([ 'instance' => [ 'debug' => true, ], 'logger' => [ 'driver' => '\Psr\Log\NullLogger' ], 'http' => [ 'timeout' => 15 ], 'cache' => [ 'enabled' => false, ] ]); $request = Request::create( 'http://localhost:8000', 'POST', [], // parameters [], // cookies [], // files $_SERVER, $payload ); $request->headers->set('accept', $accept); $response = $server->outbox('bob@localhost:8000')->post($request); // Assert response type $this->assertInstanceOf(Response::class, $response); // Assert HTTP status code $this->assertEquals( $code, $response->getStatusCode() ); } } __halt_compiler();----SIGNATURE:----L/ui3FJ6X3Km0C9ZtQGAucpqcpfwg1VRwtsXTGu0iGSbXuy6xvR9UZJXhoZ0YmLnPaRFXF1TA+9yeSOatPfsqfZm+AhYiLsw4bqAGTmHOouSd2tDUDMwHFGtU/iZba2KqfsLBknFhmU3v4lEl/32F5gYAiSMEeEhDSjwBycVB9jbyV5d0i7yzMSRBd+rTunN7oPZRecnMmXbotyoZD3+dKXDeeLuTgGYDaZmbxNDiwoVKN+Pt/3TC+VcrE6xuJbWRWXKm25+zHSRiye4kue0WXJMAec78nAfws4kMMw7r6zOr+nQmn7pzVI797rhqTAgKvyoK1yeW4SJPfpa73n/pECexS65QK81qGnaGWnTlvxLCIZCe5GwKBKInBkUy95cdkVyvk8Yrj4R4T5k3zXfl9JtHV0sWOv3NES6S+0cuYt/JacTFkUyBmXjzW25jO/Gr5nCV75jdTsFyYX2qtKgWyk0vCd/JEF/rFpOaKk2/khwku04zZcWVke58QUiBC9ZV75cHQY/c93DRsEu/Sf5+4kS9J0YhLgOki39BuSkYc9sMuaCWF+TB93m7G4/wbXSZ2i494TV+7sRdwxXmrcjPnxgew+mT2Rv9v4YrErcBXWQQUKU/WUZKxaSKTzQKUIZQb7HFmtidQS+rL5kZHcLeqb46+aBU8YUqs2wi1fJUgg=----ATTACHMENT:----OTY5MTYxNzAyNDUyNDk5NiA4ODQwNjMyNzYxNDI0MyA5NDg1MjYxNjEyMDMwMDQ4