validate(); $this->assertEquals([], $components->getErrors()); $this->assertTrue($result); $this->assertAllInstanceOf(\cebe\openapi\spec\Schema::class, $components->schemas); $this->assertCount(3, $components->schemas); $this->assertArrayHasKey('GeneralError', $components->schemas); $this->assertArrayHasKey('Category', $components->schemas); $this->assertArrayHasKey('Tag', $components->schemas); $this->assertAllInstanceOf(\cebe\openapi\spec\Response::class, $components->responses); $this->assertCount(3, $components->responses); $this->assertArrayHasKey('NotFound', $components->responses); $this->assertArrayHasKey('IllegalInput', $components->responses); $this->assertArrayHasKey('GeneralError', $components->responses); $this->assertAllInstanceOf(\cebe\openapi\spec\Parameter::class, $components->parameters); $this->assertCount(2, $components->parameters); $this->assertArrayHasKey('skipParam', $components->parameters); $this->assertArrayHasKey('limitParam', $components->parameters); $this->assertAllInstanceOf(\cebe\openapi\spec\Example::class, $components->examples); $this->assertCount(0, $components->examples); // TODO $this->assertAllInstanceOf(\cebe\openapi\spec\RequestBody::class, $components->requestBodies); $this->assertCount(0, $components->requestBodies); // TODO $this->assertAllInstanceOf(\cebe\openapi\spec\Header::class, $components->headers); $this->assertCount(0, $components->headers); // TODO $this->assertAllInstanceOf(\cebe\openapi\spec\SecurityScheme::class, $components->securitySchemes); $this->assertCount(2, $components->securitySchemes); $this->assertArrayHasKey('api_key', $components->securitySchemes); $this->assertArrayHasKey('petstore_auth', $components->securitySchemes); $this->assertAllInstanceOf(\cebe\openapi\spec\Link::class, $components->links); $this->assertCount(0, $components->links); // TODO $this->assertAllInstanceOf(\cebe\openapi\spec\Callback::class, $components->callbacks); $this->assertCount(0, $components->callbacks); // TODO } public function assertAllInstanceOf($className, $array) { foreach($array as $k => $v) { $this->assertInstanceOf($className, $v, "Asserting that item with key '$k' is instance of $className"); } } }