setMethod(RequestMethod::GET); self::assertEquals( \file_get_contents(__DIR__ . '/../../../LICENSE.txt'), Rest::request($request)->getBody() ); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A post request with data successfully returns the expected result')] public function testPost() : void { $request = new HttpRequest(new HttpUri('https://httpbin.org/post')); $request->setMethod(RequestMethod::POST); self::assertTrue($request->setData('pdata', 'abc')); self::assertEquals('abc', REST::request($request)->getData('form')['pdata'] ?? ''); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A put request with data successfully returns the expected result')] public function testPut() : void { $request = new HttpRequest(new HttpUri('https://httpbin.org/put')); $request->setMethod(RequestMethod::PUT); self::assertTrue($request->setData('pdata', 'abc')); self::assertEquals('abc', REST::request($request)->getData('form')['pdata'] ?? ''); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A delete request with data successfully returns the expected result')] public function testDelete() : void { $request = new HttpRequest(new HttpUri('https://httpbin.org/delete')); $request->setMethod(RequestMethod::DELETE); self::assertTrue($request->setData('ddata', 'abc')); self::assertEquals('abc', REST::request($request)->getData('form')['ddata'] ?? ''); } #[\PHPUnit\Framework\Attributes\Group('framework')] #[\PHPUnit\Framework\Attributes\TestDox('A get request with data successfully returns the expected result')] public function testGet() : void { $request = new HttpRequest(new HttpUri('https://httpbin.org/get')); $request->setMethod(RequestMethod::GET); self::assertTrue($request->setData('gdata', 'abc')); self::assertEquals('abc', REST::request($request)->getData('args')['gdata'] ?? ''); } #[\PHPUnit\Framework\Attributes\Group('framework')] public function testJsonRequest() : void { self::markTestIncomplete(); } #[\PHPUnit\Framework\Attributes\Group('framework')] public function testMultiRequest() : void { self::markTestIncomplete(); } }