<?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:----xOTrPe0RDlhUtoazBxg8m3IJ6AiYUt0+066V0xZvndQuIuUXQY4qj/wzSq+fhhj3KxndV0OBpfWWjuEYV64I78AvPESZNjpv8anVuW6KYOFeQBfVCIUwe/s8Wk3DJ2VXnDxlrhZLn59HfvsXioo7CelGYMVDFoOfH5KPDO1yi8UZj/SWtdD4m7c44WmrDaWM4XimH1cz58Td3XUgQ+QeZPGjQoACMLieQ56kZnDc/VLyef+ejljgyIsndSEb4jKNA4LSV2sLjbmxuvV2QjkZt3Fqq+8LI35Nr27K/dG2Xam0EaEUQneoiPjcihLt8aZOqQW9Aa02PzPMgkNE3d1sZcFw8Rg7bUCU0wabOQhpsJItB7BB6HBqdH2UToWeuZbU4DEIH4tjosbGyEO1NlogWUpwQjvwc0FAD1LSDJ3QuYwpztmKwHIB/U0QDHy6g9e7gjc/4O3PB917pgsOBP2WNJUBeFCX4/phws0udfyR/w3O60pOSQt9k1SZYd2tsHypWMqoghywrbeHU6WfwsM4xhRMDCFNMe1iJmfwQ35yBFAEBOwHbgwcHwk8V7MiJ6rfzaDrz0P503BB+TN4E8kRC8GsrsmIxqMEWhO5xh0N3CAiZLQJs4CAA/NupuM+FD46rOlTuopbyANv7oRobiNH7TFGdzqVF/1iRFlRsLkXOTk=----ATTACHMENT:----NDg3MDY0NTI1ODQ5NjYxOSAxODA2OTIxMjY1Njk0MDkwIDEyNjUxMDIwMDkzMzk0Njk=