From a2946cd5f379181fa2b27aefab2a3a5cba7ea206 Mon Sep 17 00:00:00 2001 From: Thomas Ploch Date: Mon, 15 Nov 2021 21:14:27 +0100 Subject: [PATCH] Fixing test suite after rebase massacre --- src/Exception/ExceptionMap.php | 7 ++- src/Json.php | 4 +- src/Registry/Decorators/CachingDecorator.php | 3 +- src/Registry/GuzzlePromiseAsyncRegistry.php | 2 +- src/Registry/Psr18SyncRegistry.php | 5 ++- src/Requests.php | 45 ++++++++++---------- src/Requests/Functions.php | 30 ++++++------- test/IntegrationTest.php | 1 - test/Requests/FunctionsTest.php | 35 +++++++-------- test/RequestsTest.php | 16 +++---- test/Schema/AvroNameTest.php | 6 ++- test/Schema/AvroReferenceTest.php | 7 +-- 12 files changed, 80 insertions(+), 81 deletions(-) diff --git a/src/Exception/ExceptionMap.php b/src/Exception/ExceptionMap.php index 1bc6dec..da2e431 100644 --- a/src/Exception/ExceptionMap.php +++ b/src/Exception/ExceptionMap.php @@ -39,7 +39,10 @@ private function __construct() { $factoryFn = static function (string $exceptionClass): callable { return static function (int $errorCode, string $errorMessage) use ($exceptionClass): SchemaRegistryException { - return new $exceptionClass($errorMessage, $errorCode); + /** @var SchemaRegistryException $e */ + $e = new $exceptionClass($errorMessage, $errorCode); + + return $e; }; }; @@ -84,7 +87,7 @@ public function hasMappableError(ResponseInterface $response): bool /** * @param ResponseInterface $response - * @return array + * @return array */ private function guardAgainstMissingErrorCode(ResponseInterface $response): array { diff --git a/src/Json.php b/src/Json.php index 1c35d32..2e7c233 100644 --- a/src/Json.php +++ b/src/Json.php @@ -24,9 +24,9 @@ public static function validateStringAsJson(string $schema): string /** * @param string $jsonString - * @param int $depth + * @param int<1, max> $depth * - * @return mixed + * @return mixed|array * * @throws JsonException */ diff --git a/src/Registry/Decorators/CachingDecorator.php b/src/Registry/Decorators/CachingDecorator.php index 9cdfe78..77d56de 100644 --- a/src/Registry/Decorators/CachingDecorator.php +++ b/src/Registry/Decorators/CachingDecorator.php @@ -7,8 +7,9 @@ use AvroSchema; use Exception; use FlixTech\SchemaRegistryApi\Exception\SchemaRegistryException; -use FlixTech\SchemaRegistryApi\Schema\AvroReference; +use FlixTech\SchemaRegistryApi\Registry; use FlixTech\SchemaRegistryApi\Registry\Cache\CacheAdapter; +use FlixTech\SchemaRegistryApi\Schema\AvroReference; use GuzzleHttp\Promise\PromiseInterface; use function call_user_func; diff --git a/src/Registry/GuzzlePromiseAsyncRegistry.php b/src/Registry/GuzzlePromiseAsyncRegistry.php index 2bf6123..38f66ed 100644 --- a/src/Registry/GuzzlePromiseAsyncRegistry.php +++ b/src/Registry/GuzzlePromiseAsyncRegistry.php @@ -9,11 +9,11 @@ use FlixTech\SchemaRegistryApi\AsynchronousRegistry; use FlixTech\SchemaRegistryApi\Constants; use FlixTech\SchemaRegistryApi\Exception\ExceptionMap; -use FlixTech\SchemaRegistryApi\Schema\AvroReference; use FlixTech\SchemaRegistryApi\Exception\RuntimeException; use FlixTech\SchemaRegistryApi\Exception\SchemaRegistryException; use FlixTech\SchemaRegistryApi\Json; use FlixTech\SchemaRegistryApi\Requests; +use FlixTech\SchemaRegistryApi\Schema\AvroReference; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Promise\PromiseInterface; diff --git a/src/Registry/Psr18SyncRegistry.php b/src/Registry/Psr18SyncRegistry.php index 674329d..039e997 100644 --- a/src/Registry/Psr18SyncRegistry.php +++ b/src/Registry/Psr18SyncRegistry.php @@ -13,6 +13,7 @@ use FlixTech\SchemaRegistryApi\Exception\SchemaRegistryException; use FlixTech\SchemaRegistryApi\Json; use FlixTech\SchemaRegistryApi\Requests; +use FlixTech\SchemaRegistryApi\Schema\AvroReference; use FlixTech\SchemaRegistryApi\SynchronousRegistry; use Psr\Http\Client\ClientExceptionInterface; use Psr\Http\Client\ClientInterface; @@ -37,9 +38,9 @@ public function __construct(ClientInterface $client) $this->map = ExceptionMap::instance(); } - public function register(string $subject, AvroSchema $schema): int + public function register(string $subject, AvroSchema $schema, AvroReference ...$references): int { - $request = Requests::registerNewSchemaVersionWithSubjectRequest((string)$schema, $subject); + $request = Requests::registerNewSchemaVersionWithSubjectRequest((string)$schema, $subject, ...$references); $response = $this->makeRequest($request); $this->guardAgainstErrorResponse($response); diff --git a/src/Requests.php b/src/Requests.php index 4b0a8a1..6c3beb3 100644 --- a/src/Requests.php +++ b/src/Requests.php @@ -5,6 +5,7 @@ namespace FlixTech\SchemaRegistryApi; use Assert\Assert; +use FlixTech\SchemaRegistryApi\Schema\AvroReference; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Utils; use Psr\Http\Message\RequestInterface; @@ -19,7 +20,7 @@ public static function allSubjectsRequest(): RequestInterface { return new Request( 'GET', - '/subjects', + 'subjects', Constants::ACCEPT_HEADER ); } @@ -28,7 +29,7 @@ public static function allSubjectVersionsRequest(string $subjectName): RequestIn { return new Request( 'GET', - Utils::uriFor("/subjects/$subjectName/versions"), + Utils::uriFor("subjects/$subjectName/versions"), Constants::ACCEPT_HEADER ); } @@ -37,29 +38,29 @@ public static function singleSubjectVersionRequest(string $subjectName, string $ { return new Request( 'GET', - Utils::uriFor("/subjects/$subjectName/versions/$versionId"), + Utils::uriFor("subjects/$subjectName/versions/$versionId"), Constants::ACCEPT_HEADER ); } - public static function prepareJsonSchemaForTransfer(string $schema): string + public static function prepareJsonSchemaForTransfer(string $schema, AvroReference ...$references): string { - $decoded = Json::decode($schema); - - if (is_array($decoded) && array_key_exists('schema', $decoded)) { - return Json::encode($decoded); - } + $return = [ + 'schema' => $schema + ]; - return Json::encode(['schema' => Json::encode($decoded)]); + return !$references + ? Json::encode($return) + : Json::encode(array_merge($return, ['references' => $references])); } - public static function registerNewSchemaVersionWithSubjectRequest(string $schema, string $subjectName): RequestInterface + public static function registerNewSchemaVersionWithSubjectRequest(string $schema, string $subjectName, AvroReference ...$references): RequestInterface { return new Request( 'POST', - Utils::uriFor("/subjects/$subjectName/versions"), + Utils::uriFor("subjects/$subjectName/versions"), Constants::CONTENT_TYPE_HEADER + Constants::ACCEPT_HEADER, - self::prepareJsonSchemaForTransfer(Json::validateStringAsJson($schema)) + self::prepareJsonSchemaForTransfer(Json::validateStringAsJson($schema), ...$references), ); } @@ -67,7 +68,7 @@ public static function checkSchemaCompatibilityAgainstVersionRequest(string $sch { return new Request( 'POST', - Utils::uriFor("/compatibility/subjects/$subjectName/versions/$versionId"), + Utils::uriFor("compatibility/subjects/$subjectName/versions/$versionId"), Constants::CONTENT_TYPE_HEADER + Constants::ACCEPT_HEADER, self::prepareJsonSchemaForTransfer(Json::validateStringAsJson($schema)) ); @@ -77,7 +78,7 @@ public static function checkIfSubjectHasSchemaRegisteredRequest(string $subjectN { return new Request( 'POST', - Utils::uriFor("/subjects/$subjectName"), + Utils::uriFor("subjects/$subjectName"), Constants::CONTENT_TYPE_HEADER + Constants::ACCEPT_HEADER, self::prepareJsonSchemaForTransfer(Json::validateStringAsJson($schema)) ); @@ -87,7 +88,7 @@ public static function schemaRequest(string $id): RequestInterface { return new Request( 'GET', - Utils::uriFor("/schemas/ids/$id"), + Utils::uriFor("schemas/ids/$id"), Constants::ACCEPT_HEADER ); } @@ -96,7 +97,7 @@ public static function defaultCompatibilityLevelRequest(): RequestInterface { return new Request( 'GET', - '/config', + 'config', Constants::ACCEPT_HEADER ); } @@ -130,7 +131,7 @@ public static function changeDefaultCompatibilityLevelRequest(string $level): Re { return new Request( 'PUT', - '/config', + 'config', Constants::ACCEPT_HEADER, self::prepareCompatibilityLevelForTransport(self::validateCompatibilityLevel($level)) ); @@ -140,7 +141,7 @@ public static function subjectCompatibilityLevelRequest(string $subjectName): Re { return new Request( 'GET', - Utils::uriFor("/config/$subjectName"), + Utils::uriFor("config/$subjectName"), Constants::ACCEPT_HEADER ); } @@ -149,7 +150,7 @@ public static function changeSubjectCompatibilityLevelRequest(string $subjectNam { return new Request( 'PUT', - Utils::uriFor("/config/$subjectName"), + Utils::uriFor("config/$subjectName"), Constants::ACCEPT_HEADER, self::prepareCompatibilityLevelForTransport(self::validateCompatibilityLevel($level)) ); @@ -194,7 +195,7 @@ public static function deleteSubjectRequest(string $subjectName, bool $permanent return new Request( 'DELETE', - Utils::uriFor("/subjects/$subjectName?permanent=$query"), + Utils::uriFor("subjects/$subjectName?permanent=$query"), Constants::ACCEPT_HEADER ); } @@ -211,7 +212,7 @@ public static function deleteSubjectVersionRequest(string $subjectName, string $ return new Request( 'DELETE', - Utils::uriFor("/subjects/$subjectName/versions/$versionId?permanent=$query"), + Utils::uriFor("subjects/$subjectName/versions/$versionId?permanent=$query"), Constants::ACCEPT_HEADER ); } diff --git a/src/Requests/Functions.php b/src/Requests/Functions.php index 3428c11..078e718 100644 --- a/src/Requests/Functions.php +++ b/src/Requests/Functions.php @@ -4,7 +4,6 @@ use Assert\Assert; use GuzzleHttp\Psr7\Request; -use GuzzleHttp\Psr7\Utils; use InvalidArgumentException; use JsonException; use Psr\Http\Message\RequestInterface; @@ -21,10 +20,11 @@ use const FlixTech\SchemaRegistryApi\Constants\VERSION_LATEST; use function implode; use function json_decode; +use function sprintf; /** * @param string $jsonString - * @param int $depth + * @param int<1, max> $depth * * @return mixed * @@ -82,7 +82,7 @@ function allSubjectsRequest(): RequestInterface { return new Request( 'GET', - '/subjects', + 'subjects', ACCEPT_HEADER ); } @@ -98,7 +98,7 @@ function allSubjectVersionsRequest(string $subjectName): RequestInterface { return new Request( 'GET', - Utils::uriFor("/subjects/$subjectName/versions"), + sprintf("subjects/%s/versions", $subjectName), ACCEPT_HEADER ); } @@ -115,7 +115,7 @@ function singleSubjectVersionRequest(string $subjectName, string $versionId): Re { return new Request( 'GET', - Utils::uriFor("/subjects/$subjectName/versions/$versionId"), + sprintf("subjects/%s/versions/%s", $subjectName, $versionId), ACCEPT_HEADER ); } @@ -133,7 +133,7 @@ function registerNewSchemaVersionWithSubjectRequest(string $schema, string $subj { return new Request( 'POST', - Utils::uriFor("/subjects/$subjectName/versions"), + sprintf("subjects/%s/versions", $subjectName), CONTENT_TYPE_HEADER + ACCEPT_HEADER, prepareJsonSchemaForTransfer(validateSchemaStringAsJson($schema)) ); @@ -153,7 +153,7 @@ function checkSchemaCompatibilityAgainstVersionRequest(string $schema, string $s { return new Request( 'POST', - Utils::uriFor("/compatibility/subjects/$subjectName/versions/$versionId"), + sprintf("compatibility/subjects/%s/versions/%s", $subjectName, $versionId), CONTENT_TYPE_HEADER + ACCEPT_HEADER, prepareJsonSchemaForTransfer(validateSchemaStringAsJson($schema)) ); @@ -172,7 +172,7 @@ function checkIfSubjectHasSchemaRegisteredRequest(string $subjectName, string $s { return new Request( 'POST', - Utils::uriFor("/subjects/$subjectName"), + sprintf("subjects/%s", $subjectName), CONTENT_TYPE_HEADER + ACCEPT_HEADER, prepareJsonSchemaForTransfer(validateSchemaStringAsJson($schema)) ); @@ -188,7 +188,7 @@ function schemaRequest(string $id): RequestInterface { return new Request( 'GET', - Utils::uriFor("/schemas/ids/$id"), + sprintf("schemas/ids/%s", $id), ACCEPT_HEADER ); } @@ -202,7 +202,7 @@ function defaultCompatibilityLevelRequest(): RequestInterface { return new Request( 'GET', - '/config', + 'config', ACCEPT_HEADER ); } @@ -219,7 +219,7 @@ function changeDefaultCompatibilityLevelRequest(string $level): RequestInterface { return new Request( 'PUT', - '/config', + 'config', ACCEPT_HEADER, prepareCompatibilityLevelForTransport(validateCompatibilityLevel($level)) ); @@ -236,7 +236,7 @@ function subjectCompatibilityLevelRequest(string $subjectName): RequestInterface { return new Request( 'GET', - Utils::uriFor("/config/$subjectName"), + sprintf("config/%s", $subjectName), ACCEPT_HEADER ); } @@ -254,7 +254,7 @@ function changeSubjectCompatibilityLevelRequest(string $subjectName, string $lev { return new Request( 'PUT', - Utils::uriFor("/config/$subjectName"), + sprintf("config/%s", $subjectName), ACCEPT_HEADER, prepareCompatibilityLevelForTransport(validateCompatibilityLevel($level)) ); @@ -377,7 +377,7 @@ function deleteSubjectRequest(string $subjectName): RequestInterface { return new Request( 'DELETE', - Utils::uriFor("/subjects/$subjectName"), + sprintf("subjects/%s", $subjectName), ACCEPT_HEADER ); } @@ -394,7 +394,7 @@ function deleteSubjectVersionRequest(string $subjectName, string $versionId): Re { return new Request( 'DELETE', - Utils::uriFor("/subjects/$subjectName/versions/$versionId"), + sprintf("subjects/%s/versions/%s", $subjectName, $versionId), ACCEPT_HEADER ); } diff --git a/test/IntegrationTest.php b/test/IntegrationTest.php index a3027b0..0e440b2 100644 --- a/test/IntegrationTest.php +++ b/test/IntegrationTest.php @@ -17,7 +17,6 @@ use GuzzleHttp\Client; use GuzzleHttp\ClientInterface; use GuzzleHttp\Exception\RequestException; -use GuzzleHttp\Psr7\Utils; use PHPUnit\Framework\TestCase; use Psr\Http\Message\ResponseInterface; diff --git a/test/Requests/FunctionsTest.php b/test/Requests/FunctionsTest.php index ca0fe7c..14ced3c 100644 --- a/test/Requests/FunctionsTest.php +++ b/test/Requests/FunctionsTest.php @@ -51,7 +51,7 @@ public function it_should_produce_a_Request_to_get_all_subjects(): void $request = allSubjectsRequest(); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/subjects', $request->getUri()); + self::assertEquals('subjects', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -63,7 +63,7 @@ public function it_should_produce_a_Request_to_get_all_subject_versions(): void $request = allSubjectVersionsRequest('test'); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/subjects/test/versions', $request->getUri()); + self::assertEquals('subjects/test/versions', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -75,7 +75,7 @@ public function it_should_produce_a_Request_to_get_a_specific_subject_version(): $request = singleSubjectVersionRequest('test', '3'); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/subjects/test/versions/3', $request->getUri()); + self::assertEquals('subjects/test/versions/3', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -87,7 +87,7 @@ public function it_should_produce_a_request_to_register_a_new_schema_version(): $request = registerNewSchemaVersionWithSubjectRequest('{"type": "string"}', 'test'); self::assertEquals('POST', $request->getMethod()); - self::assertEquals('/subjects/test/versions', $request->getUri()); + self::assertEquals('subjects/test/versions', $request->getUri()); self::assertEquals( [CONTENT_TYPE => [CONTENT_TYPE_HEADER[CONTENT_TYPE]]] + [ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders() @@ -97,7 +97,7 @@ public function it_should_produce_a_request_to_register_a_new_schema_version(): $request = registerNewSchemaVersionWithSubjectRequest('{"schema": "{\"type\": \"string\"}"}', 'test'); self::assertEquals('POST', $request->getMethod()); - self::assertEquals('/subjects/test/versions', $request->getUri()); + self::assertEquals('subjects/test/versions', $request->getUri()); self::assertEquals( [CONTENT_TYPE => [CONTENT_TYPE_HEADER[CONTENT_TYPE]]] + [ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders() @@ -117,7 +117,7 @@ public function it_should_produce_a_request_to_check_schema_compatibility_agains ); self::assertEquals('POST', $request->getMethod()); - self::assertEquals('/compatibility/subjects/test/versions/latest', $request->getUri()); + self::assertEquals('compatibility/subjects/test/versions/latest', $request->getUri()); self::assertEquals('{"schema":"{\"type\":\"test\"}"}', $request->getBody()->getContents()); self::assertEquals( [CONTENT_TYPE => [CONTENT_TYPE_HEADER[CONTENT_TYPE]]] + [ACCEPT => [ACCEPT_HEADER[ACCEPT]]], @@ -133,7 +133,7 @@ public function it_should_produce_a_request_to_check_if_a_subject_already_has_a_ $request = checkIfSubjectHasSchemaRegisteredRequest('test', '{"type":"test"}'); self::assertEquals('POST', $request->getMethod()); - self::assertEquals('/subjects/test', $request->getUri()); + self::assertEquals('subjects/test', $request->getUri()); self::assertEquals('{"schema":"{\"type\":\"test\"}"}', $request->getBody()->getContents()); self::assertEquals( [CONTENT_TYPE => [CONTENT_TYPE_HEADER[CONTENT_TYPE]]] + [ACCEPT => [ACCEPT_HEADER[ACCEPT]]], @@ -149,7 +149,7 @@ public function it_should_produce_a_request_to_get_a_specific_schema_by_id(): vo $request = schemaRequest('3'); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/schemas/ids/3', $request->getUri()); + self::assertEquals('schemas/ids/3', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -161,7 +161,7 @@ public function it_should_produce_a_request_to_get_the_global_compatibility_leve $request = defaultCompatibilityLevelRequest(); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/config', $request->getUri()); + self::assertEquals('config', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -173,7 +173,7 @@ public function it_should_produce_a_request_to_change_the_global_compatibility_l $request = changeDefaultCompatibilityLevelRequest(COMPATIBILITY_FULL); self::assertEquals('PUT', $request->getMethod()); - self::assertEquals('/config', $request->getUri()); + self::assertEquals('config', $request->getUri()); self::assertEquals('{"compatibility":"FULL"}', $request->getBody()->getContents()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -186,7 +186,7 @@ public function it_should_produce_a_request_to_get_the_subject_compatibility_lev $request = subjectCompatibilityLevelRequest('test'); self::assertEquals('GET', $request->getMethod()); - self::assertEquals('/config/test', $request->getUri()); + self::assertEquals('config/test', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -198,7 +198,7 @@ public function it_should_produce_a_request_to_change_the_subject_compatibility_ $request = changeSubjectCompatibilityLevelRequest('test', COMPATIBILITY_FORWARD); self::assertEquals('PUT', $request->getMethod()); - self::assertEquals('/config/test', $request->getUri()); + self::assertEquals('config/test', $request->getUri()); self::assertEquals('{"compatibility":"FORWARD"}', $request->getBody()->getContents()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -225,11 +225,6 @@ public function it_should_prepare_a_JSON_schema_for_transfer(): void '{"schema":"{\"type\":\"string\"}"}', prepareJsonSchemaForTransfer('{"type": "string"}') ); - - self::assertJsonStringEqualsJsonString( - '{"schema":"{\"type\": \"string\"}"}', - prepareJsonSchemaForTransfer('{"schema":"{\"type\": \"string\"}"}') - ); } /** @@ -367,7 +362,7 @@ public function it_should_produce_a_valid_subject_deletion_request(): void $request = deleteSubjectRequest('test'); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test', $request->getUri()); + self::assertEquals('subjects/test', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } @@ -379,13 +374,13 @@ public function it_should_produce_a_valid_subject_version_deletion_request(): vo $request = deleteSubjectVersionRequest('test', VERSION_LATEST); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test/versions/latest', $request->getUri()); + self::assertEquals('subjects/test/versions/latest', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); $request = deleteSubjectVersionRequest('test', '5'); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test/versions/5', $request->getUri()); + self::assertEquals('subjects/test/versions/5', $request->getUri()); self::assertEquals([ACCEPT => [ACCEPT_HEADER[ACCEPT]]], $request->getHeaders()); } } diff --git a/test/RequestsTest.php b/test/RequestsTest.php index 5b44a9b..0b41d6a 100644 --- a/test/RequestsTest.php +++ b/test/RequestsTest.php @@ -72,7 +72,8 @@ public function it_should_produce_a_request_to_register_a_new_schema_version(str self::assertJsonStringEqualsJsonString($finalSchema, $request->getBody()->getContents()); } - public static function dataForRegisteringSchemas(): Generator { + public static function dataForRegisteringSchemas(): Generator + { yield 'Schema without schema key' => [ '{"type":"string"}', '{"schema":"{\"type\":\"string\"}"}', @@ -225,11 +226,6 @@ public function it_should_prepare_a_JSON_schema_for_transfer(): void '{"schema":"{\"type\":\"string\"}"}', Requests::prepareJsonSchemaForTransfer('{"type":"string"}') ); - - self::assertJsonStringEqualsJsonString( - '{"schema":"{\"type\": \"string\"}"}', - Requests::prepareJsonSchemaForTransfer('{"schema":"{\"type\": \"string\"}"}') - ); } /** @@ -367,7 +363,7 @@ public function it_should_produce_a_valid_subject_deletion_request(): void $request = Requests::deleteSubjectRequest('test'); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test?permanent=false', $request->getUri()); + self::assertEquals('subjects/test?permanent=false', $request->getUri()); self::assertEquals([Constants::ACCEPT => [Constants::ACCEPT_HEADER[Constants::ACCEPT]]], $request->getHeaders()); $request = Requests::deleteSubjectRequest('test', false); @@ -379,7 +375,7 @@ public function it_should_produce_a_valid_subject_deletion_request(): void $request = Requests::deleteSubjectRequest('test', true); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test?permanent=true', $request->getUri()); + self::assertEquals('subjects/test?permanent=true', $request->getUri()); self::assertEquals([Constants::ACCEPT => [Constants::ACCEPT_HEADER[Constants::ACCEPT]]], $request->getHeaders()); } @@ -391,7 +387,7 @@ public function it_should_produce_a_valid_subject_version_deletion_request(): vo $request = Requests::deleteSubjectVersionRequest('test', Constants::VERSION_LATEST, false); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test/versions/latest?permanent=false', $request->getUri()); + self::assertEquals('subjects/test/versions/latest?permanent=false', $request->getUri()); self::assertEquals([Constants::ACCEPT => [Constants::ACCEPT_HEADER[Constants::ACCEPT]]], $request->getHeaders()); $request = Requests::deleteSubjectVersionRequest('test', Constants::VERSION_LATEST); @@ -403,7 +399,7 @@ public function it_should_produce_a_valid_subject_version_deletion_request(): vo $request = Requests::deleteSubjectVersionRequest('test', '5', false); self::assertEquals('DELETE', $request->getMethod()); - self::assertEquals('/subjects/test/versions/5?permanent=false', $request->getUri()); + self::assertEquals('subjects/test/versions/5?permanent=false', $request->getUri()); self::assertEquals([Constants::ACCEPT => [Constants::ACCEPT_HEADER[Constants::ACCEPT]]], $request->getHeaders()); $request = Requests::deleteSubjectVersionRequest('test', '5', true); diff --git a/test/Schema/AvroNameTest.php b/test/Schema/AvroNameTest.php index d75d926..1ca73d4 100644 --- a/test/Schema/AvroNameTest.php +++ b/test/Schema/AvroNameTest.php @@ -15,7 +15,8 @@ class AvroNameTest extends TestCase * @dataProvider avroReferences * @test */ - public function it_should_only_be_constructable_from_a_valid_Avro_reference(string $fullName, bool $isValid): void { + public function it_should_only_be_constructable_from_a_valid_Avro_reference(string $fullName, bool $isValid): void + { if (!$isValid) { $this->expectException(InvalidArgumentException::class); } @@ -23,7 +24,8 @@ public function it_should_only_be_constructable_from_a_valid_Avro_reference(stri $this->assertSame((string) new AvroName($fullName), $fullName); } - public static function avroReferences(): Generator { + public static function avroReferences(): Generator + { yield 'Valid root name' => ['test', true]; yield 'Valid full name' => ['test.example', true]; yield 'Empty full name' => ['', false]; diff --git a/test/Schema/AvroReferenceTest.php b/test/Schema/AvroReferenceTest.php index c3fe852..98950e1 100644 --- a/test/Schema/AvroReferenceTest.php +++ b/test/Schema/AvroReferenceTest.php @@ -21,7 +21,8 @@ class AvroReferenceTest extends TestCase * @param bool $isValid * @param string $expectedJson */ - public function it_should_be_constructable(string $avroName, string $subject, $version, bool $isValid, ?string $expectedJson): void { + public function it_should_be_constructable(string $avroName, string $subject, $version, bool $isValid, ?string $expectedJson): void + { if (!$isValid) { $this->expectException(InvalidArgumentException::class); } @@ -32,7 +33,8 @@ public function it_should_be_constructable(string $avroName, string $subject, $v ); } - public static function references(): Generator { + public static function references(): Generator + { yield 'Valid version with latest' => [ 'test.example.MyRecord', 'example-value', @@ -68,6 +70,5 @@ public static function references(): Generator { false, null, ]; - } }